architecture – How to store a branching linked list in a database

I am trying to model an HVAC system for simulation purposes, which will consist of a series of components linked together by airflow and electrical flow paths. I’m trying to figure out how to best represent this in the database. Basically each component has to have one or more inputs and one or more outputs (with both indicating whether they are airflow or electrical), and we need some way of tracking what component they are linked to “next” in the chain.

Now, the simple way I can think of is having a table that is more or less:

Component ID | Connection Type  | Connection Number | Flow Type | Connected Component
      1      |       output     |        1          | Electrical|          2
      1      |       output     |        2          |     Air   |          2 
      1      |       output     |        3          |     Air   |          3
      2      |       input      |        1          | Electrical|          1
      2      |       input      |        2          |     Air   |          1
      3      |       input      |        1          |     Air   |          1

But this feels like its “wrong” in some way. It seems right in the sense that if I wanted to know all of a component’s connections, I could easily get it, but it contains redundant data (I could assume component 2’s inputs by looking for rows where the connected component is 2). It also feels hard to get the whole system from this data, as I’d have to step component by component until I built the whole thing, however, I’m not sure that’s really an issue.

Anyone deal with something like this?

e.g. the above data represents a simple system like:

 1 = 2
   
     3

Where 1 is connected to both 2 and 3, with an air and electrical connection to 2 but only an air connection to 3 (this is largely demonstrative, not an actual use case).

computer architecture – In a single cycle datapath, do ‘decode’ and ‘operand fetch’ occur simultaneously?

After instruction has been fetched, does it go to control unit and register file at the same time or one after the other?
For example if the control unit and register read both have 80ps delay, and we’re calculating the total delay for a cycle, would we take their delay as 80ns(if they occur simultaneously) or if they happen one after the other so in that case delay of decode and operand fetch would be 160ns. Which one is correct?

aws – Serverless game server architecture

First post on the software engineering stack exchange, I hope the question fits the purpose of this sub.

I’m building a serverless game server with the following architecture and was wondering if anyone here has already attempted this and if it’s a valid strategy. Also if you’re aware of any caveats I should know of, I will be grateful for any input here.

I’ve run into a problem here which I’m not completely sure how to address.

The infrastructure

I am using is AWS Lambda and SQS

How it works

The core of the game is intended to work as follows:

A game consists of a number of rounds.
Each round has a duration of 10 seconds, has one question and one correct answer.
Each player must have their answer in before the end of the round.

I.e. a game would look like this:
Game started at 10:00:00
round 1 starts at 10:00:00
round 1 ends at 10:00:10
round 2 starts at 10:00:10
round 2 ends at 10:00:20
etc…

My approach:
When all players have confirmed their participation, the game is created.
This will queue up a delayed SQS message that will trigger a lambda function for each round. Delayed by round number * 10 seconds each.

The code of this lambda function will simply round up all the answers that have been entered for its assigned round, assign a score to each and persist that to a DB and die.

The problem

Delayed SQS messages are cool and all, they do exactly what you’d expect, they only appear in the queue after your specified timeout, however, that is currently not a valid trigger for a lambda function. I’m aware SNS does serve this purpose but AFAIK there is no way to delay an SNS.publish() invocation.

What I’m bending over backwards here to avoid is to have a lambda function waiting for X amount of seconds until it publishes an SNS notification.

Are there any solutions that could help me approach my goal?

Thanks in advance

architecture – Multi-Tenant SAAS application with common backend for Mobile App and Front End Dashboard App

I have a requirement for a Mobile App to be able to write to a database managed by a backend. I will also have an admin dashboard that would retrieve data from the database, have analytics performed by the backend and present it to the View. The Front-end dashboard and the mobile app will not share any data between them and hence they need not be synchronized though I am open to suggestions here as-well. In a nutshell,

  1. The Mobile App writes to the database. Data will be JSON string.

  2. The Web App pulls data from the database and presents it to the dashboard. The Back-end will need to manage that analytics portion and paint the Front end dashboard.

  3. In addition, the backend will also need to create external notifications for SMS/Slack/Email(POP).

  4. Lastly, I also want to keep this entire application multi-tenant supporting multiple clients. Under each client there will be only one user.

As a first time Web App developer, My question is how would I go about architecting the APIs so that I don’t have a lot of duplicated code and achieve a clean architecure .I have heard of the Separation of concerns. I just don’t know how to apply that in this context.

Multi-Tenant SAAS

computer architecture – Cache Blocks Direct Mapping

If the main memory address has 18 bits (7 for tag,7 for line and 4 for word)
and each word is 8 bits.
I found that the main memory capacity is 256-KBytes, total cache lines is 128 line,
total cache words is 128*16(16 word per block/line) = 2048 words.
Then what will be the size of cache words?
I am very confusing on it. I can’t get the definition of cache words.
Can anyone tell me what is the cache words?
Thank you!

storage – Looking for architecture recommendations/critique: locally hosted neo4j db + django application on apache server

We would like to develop an application for analyzing ribosomes, which will both require some local data and yield a lot of new data as well, be quite computationally demanding. Because the types of biological data that we work with are highly unstructred and often poorly integrated, i decided to use Neo4j graph-database in production.

I am planning to host it on our university’s rack which should also make all the compute necessary for parsing and clustering readily and locally available. One issue i see ahead is the fact that some of the crystallographic files that we use as the basis for our computations are quite large (on the order of 100mb) and come in multiple formats (ex..pdb,.cif). The closest that Neo4j has to this is geo-spatial 3D Point type, but other than that it does not support this sort of storage.

Hence, it seems like the optimal thing is to commit all the string/int non-structural data to the database and store the .cif files locally in the server’s filesystem. Then, when the user queries the front-end for something, have the Django app parse the large local file and pull the necessary nomenclature/identifiers from Neo4j, respond with the result.

I have however read a few “database vs file storage” discussions and articles and decided to ask what pitfalls are there for something like this and if there is a better solution/architecture that i’m not seeing?

Thanks!

architecture – How is source code mapping usually mapped to code (data-structure-wise)?

I have written a simple toy language in XML that runs like a program. Now I would like to figure out how to do source mapping, so theoretically you could build a debugger and see what XML node is running.

<add>
  <left>
    <mul>
      <left>10</left>
      <right>20</right>
    </mul>
  </left>
  <right>
    <sub>
      <left>5</left>
      <right>2</right>
    </sub>
  </right>
</add>

Say it gets compiled down to something somewhat resembling this initial structure, but not exactly.

x = mul 10, 20
y = sub 5, 2
z = add x, y

That’s at least the final “data structure” that the code would be in:

[
  {
    type: 'var',
    name: 'x',
    assignment: {
      type: 'binary-operation',
      name: 'mul',
      left: 10,
      right: 20
    }
  },
  ...
]

The question is where should I put what in terms of mapping the source code? Do I do this?

[
  {
    type: 'var',
    name: 'x',
    assignment: {
      type: 'binary-operation',
      name: 'mul',
      left: {
        value: 10,
        lineStart: 4, 
        columnStart: ...,
        lineEnd: 4,
        columnEnd: ...,
      },
      right: {
        ...
      }
    }
  },
  ...
]

Or how does it work exactly? I’ve never seen it done.

computer architecture – DRAM Self-Refresh not the Lowest Power Mode

I have a DDR3L Samsung DRAM on my Laptop. Based on page 23 of its datasheet, IDD6 or the Self-Refresh current is much higher than IDD2P0, IDD2P1 and IDD3P, which are the Precharge/Active Power-Down modes. Of course, IDD5B (i.e., the Burst Refresh current, which is responsible for refresh when Self-Refresh is not used) should be scaled based on the refresh period and added to the latter three values. But, even after that, it seems that the Self-Refresh power mode, is not the deepest power mode in this DRAM device. Am I missing something?

terminology – What is the term for an architecture between a monolith and micro services

There are a lot.

At one end, you have the monolith, a single deployable entity that represents your entire system. At the far opposite extreme, you have microservices, small, well-bound, loosely-coupled, independently deployable pieces that form the system.

Between those, you have many different architectures.

I would consider the “majestic monolith” to be a special case of the monolithic architecture. Like a monolith, the majestic monolith is a single deployable entity. From the outside, it looks the same as a monolith. However, from the inside, there is great care to isolate different pieces or modules with well-defined interfaces between each of the modules.

You also have service-oriented architectures. I consider these to be a precursor to the microservice architecture. The pieces tend to be loosely-coupled, but they may be larger and not all of them may be independently deployable.

You also have multitier architectural patterns. Since a monolith is a single deployable entity, the deployment would account for the view layer as well as any APIs and data model. However, you could separate that out into a view layer and a data layer as two separate deployable entities. Perhaps even three tiers – a view layer, an API layer, and a data layer. And your view layer may even be a web view and a mobile app view. They aren’t end-to-end services and have some level of coupling, but could possibly be independently deployable.

It’s a good point that most people tend to talk about “monolith” versus “microservice”, but most applications tend to be somewhere in the middle of those extremes. Since it’s a spectrum, there are lots of options somewhere in the middle. Rather than having names for all of those arbitrary middle points, it’s useful to talk about being more like one of the two endpoints, and perhaps having a few somewhat well-defined concepts in the middle.

domain driven design – Clean Architecture: Can Use Cases Imply UI?

In the chapter “Business Rules” of his book “Clean Architecture”, Robert C. Martin comments on the relationship between use cases and the UI:

(…) the use case does not describe the user interface other than to informally specify the data coming in from that interface, and the data going back out through that interface. (…) Use cases do not describe how the system appears to the user. Instead, they describe the application-specific rules that govern the interaction between the users and the Entities.

Context

For some context, I’m writing a simple client app (Android) using Clean Architecture + MVP in the presentation layer. Though MVP combines the controller and presenter, I’m still trying to think of them as independent aspects of the “interface adapters” layer in Clean Architecture.

In my app, users can create new events or edit existing events via a simple form UI. Each event has a start date, an end date, and a description. In my “domain” conventions (what I understand to be the convention convenient for doing useful operations uninfluenced by any one framework), an event is a simple Kotlin data class:

data class Event(
  val startDate: LocalDate,
  val endDate: LocalDate,
  val description: String
)

My form has simple behavior:

  • Show a loading spinner while an existing event is loaded from a remote data source.
  • If the selected start date is after the selected end date, then the end date is moved to be equal to the new start date. For example, if the end date was set to 2020-06-01, then I set the start date to 2020-06-02, the end date would now also be/show 2020-06-02.
  • Show a loading spinner while the event is being saved to a remote data source.

My understanding is that Clean Architecture describes the “business rules”/”use cases”/”domain” of an application to be application-specific behaviour implemented using conventions that will not be influenced by frameworks chosen to implement details such as UI. In my case, that means working with events treating dates as LocalDates, even though my UI inputs dates as year, month, and day Ints and ouputs them as Strings.

On one hand, handling the loading state and relationship between date inputs seems like a presentation concern because my use cases shouldn’t know anything about the UI. However, leaving the controller and presenter to be interface adapters which simply translate from a framekwork-like conventions to domain-like conventions and vice versa, and leaving them unaware of each other, the domain seems like the only place left to implement these behaviors. That leaves me with a use case output port something like this:

interface EditEventOutput {
  fun showLoading()
  fun hideLoading()
  fun renderEndDate(date: LocalDate)
}

My Question

That looks like a presenter’s view interface to me, but my presenter is unaware of this behavior. I tried using more generic terms, like an isLoading Boolean instead of the terms “show” and “hide”, but that’s not solving my issue.

The interface I’ve ended up with looks like a UI! It doesn’t discuss details about the UI, like what “show loading” means (i.e. it could be a line of text in a terminal, or a fancy UI widget), but it still implies the existence of UI.

So, even though use cases do not describe how the system appears to the user, do they imply the existence of some user interface? If they should not, and we should be capable of implementing the output ports on any sort of interface adapter (maybe it doesn’t even output to a UI), then where do I implement behaviors such as handling a loading state and the relationship between my start and end date pickers?