Shorosky's avatar

TCP Sockets. Laravel or C++

Hi. I'm creating an API Laravel where some gateways will send frames with tcp sockets protocol. Some devices will expect for an ack that will be in a queue. Time delays in answer are not crucial but very important. I'm thinking about 2 possible communications:

1 Laravel has a TCP library and handles communication with devices. It has to search the device id who is starting communication and find pending acks to return back to device. The ACKs will be in a postgres database, but pending ACKs can be synchroniced with a REDIS database to have them ready when ack searching is needed as quick as possible. Once the ACK has been sent succesfully to device, it is removed from REDIS and updated in postgres with sent status.

2 Laravel synchronizes pending ACKs with REDIS database, like in a point 1, but laravel doesn't handle communication. It will do an external C++ service. REDIS database will be shared betweenn laravel and C++ service. Laravel fills REDIS database with new ACKs and C++ will consume each ACK and reporting it to Laravel to update ACK status in postgres.

Is it worth developing the TCP communication in an external service, or is it preferable to implement it in Laravel? Will be a shared REDIS database a pain in the neck?

Target is to reduce ack response time from server.

0 likes
0 replies

Please or to participate in this conversation.