1

I have a PHP socket running on port 15151 hosted on EC2 Ubuntu. I have a php project that push a message to this socket, and this message is received by clients connected to the socket are using a VB6 application.

When more than 1024 clients connect to the socket, the socket is crashing and a php error is returned

stream_select(): You MUST recompile PHP with a larger value of FD_SETSIZE. It is set to 1024, but you have descriptors numbered at least as high as 1123. --enable-fd-setsize=2048 is recommended

What I tried to do is to create a new ec2 instance, same code, socket server, same port and i have added a load balancer.

The problem is now that if a client (foo) vb6 is connected to instance 1, how the php project that send the message to this client will know that foo is connected to 1 and not to instance 2

How should I manage this

Shadow
  • 33,525
  • 10
  • 51
  • 64
Elio Chamy
  • 13
  • 4
  • We need more information, you are confusion (or using as if it was the same) socket and port. You cannot "recompile" PHP, I think you mean to "change PHP code". If you say "recompile" we could assume you are using HHVM or something similar... What did you try? What about load balancing? – matiaslauriti Dec 14 '22 at 15:17
  • I have edited my question with more details thank you – Elio Chamy Dec 14 '22 at 15:30
  • You can use the sticky session feature (also known as session affinity) to enable the load balancer to bind a user's session to a specific target. This ensures that all requests from the user during the session are sent to the same target. – Arpit Jain Dec 14 '22 at 16:35
  • Also, Application Load Balancers provide native support for WebSockets. This answer may help you : https://stackoverflow.com/questions/39336033/does-an-application-load-balancer-support-websockets – Arpit Jain Dec 14 '22 at 16:43

0 Answers0