Horizontal Scaling

Anton Tananaev 3 years ago

Usual way.

Adam 3 years ago

usual mean, hit the command api, not to LB?

Anton Tananaev 3 years ago

No, for the API you obviously hit the load balancer.

Adam 3 years ago

but i receive. 202 Accepted response.
when i see the routes, LB forward to server where not connected to the device.

Anton Tananaev 3 years ago

What is the problem with that response?

Adam 3 years ago

it means the command not receive/queue to the device because device not connected to this server, but connect to other server

Anton Tananaev 3 years ago

No, it doesn't mean that. If the device is connected to another server, the command will be sent.

Adam 3 years ago

like this, https://youtu.be/VFqorQG6zKY
the command has send to "api/commands/send" not delivered to devices

Anton Tananaev 3 years ago

It's not fully clear to me what is shown on the video. We don't know if the script is correct. I see that at least the multicast seems to be working, so both servers should receive the command.

Adam 3 years ago

this is my script

import socket
import struct

MCAST_GRP = '224.0.0.1'
MCAST_PORT = 7777

sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM, socket.IPPROTO_UDP)
sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)

sock.bind((MCAST_GRP, MCAST_PORT))
mreq = struct.pack("4sl", socket.inet_aton(MCAST_GRP), socket.INADDR_ANY)

sock.setsockopt(socket.IPPROTO_IP, socket.IP_ADD_MEMBERSHIP, mreq)

while True:
  print(sock.recv(10240))
Anton Tananaev 3 years ago

That's your multicast, but what about the device? That's the one that's not working, right?

Adam 3 years ago

yes, expected when i send command ("api/commands/send") to LB. LB forwarded to server A where not connected to the device, but server B where the server has connected to the device not received the message multicast..

Anton Tananaev 3 years ago

Then I don't understand the video at all. I see the command in your multicast console. Did I miss something?

Adam 3 years ago

hmm, can I change the multicast method to use a message broker, like MQTT, Kafka, rabbit MQ, etc..?

Anton Tananaev 3 years ago

You can implement a different synchronization method. Feel free to send a pull request.