0

What I have seen so far is that if an application does not support the actual load its possible to deploy a new instance of the same application and use a load balancers to distribute the load between the two instances.

What I don't understand at this point is that how is possible to synchronize the information between both instances.

I.e. suppose that I have two instances A and B. I make a POST petition and the load balancer redirects me to A instance, this POST petition updates a map in A instance.

After that I make a GET petition to return the information in that map, and the load balancer redirects me to the B instance, this one will return a void map as the information is only in the A instance.

Maybe I don't understand this type of scalability.

david.t_92
  • 1,971
  • 1
  • 11
  • 15
  • 2
    It is your responsibility to make the data available in the way it's required. – daniu Jul 17 '19 at 11:54
  • So, in the case that I've exposed I will need to have a common DDBB? – david.t_92 Jul 17 '19 at 11:58
  • ^ yes that's correct – Nordle Jul 17 '19 at 12:07
  • You can also use a distributed cache like Hazelcast, or explicitly reroute requests like you do for Kafka, or use a sidecar that contains that logic, or or or. – daniu Jul 17 '19 at 12:52
  • Distributed applications and load balancing work with stateless applications . Which means you don't save state on particular machine but in shared data store , so any number of instances can share/Update data. – Imran Arshad Jul 18 '19 at 23:26

1 Answers1

0

It all depends on the type of data you are updating, that is whether it is persistent data (Data which remains even after powers goes) or non-persistant data. If you want something to be constant everywhere that is the instances share the same memory so for this you can use a database, where both the instances connect and atomically update and access the data.

If the map is just a constant you create temporarily in RAM, you can simply create a constant and that won't be shared by both instances.

E.g

DATABASE (shared memory)

DB -> Table -> mapcolumn - JSON Field (mapcolumn = {} #default value)

Req -> LoadBalancer -> INSTANCE A -> DB_Connection -> updates mapcolumn -> {'key': 'value'} Req -> LoadBalancer -> INSTANCE B -> DB_Connection -> gets mapcolumn -> {'key': 'value'}

RAM Constant

Req -> LoadBalancer -> INSTANCE A -> sets mapcol constant -> mapcolumn = {'key': 'value'}

Req -> LoadBalancer -> INSTANCE B -> gets mapcolumn constant -> Null or None

Here the two instances don't use the database or shared memory.

Hopes this clears your doubt.

abhishek kasana
  • 1,462
  • 12
  • 14