PHP Threading and High Latency File Access (e.g. FTP)

This is a bit complicated, so please don't jump to conclusions, feel free to ask about something that isn't clear enough.

Basically, I have a websocket server written in PHP. Please note that messages in websocket are asynchronous, that is, the response to the request can take a lot of time, and the client continues to work all the time (if applicable).

Clients must request server access to files on other servers. It could be an FTP service or Dropbox for this.

Here, please pay attention to two questions: the connections should be separated and reused and the server will actually “freeze” while it is doing its work , so any requests are processed after the server is “frozen”.

So I thought: why not turn off file access (which freezes the server) for PHP threads ?

The problem here is twofold:

  • how to make the connection resource in the main thread (server) available for sub-streams (impossible with the stream model specified above)?
  • What happens if two threads need the same resource? This is great if one is locked until the other is over, but we still need to figure out number number 1.

, , , . PHP, , .

+3
1

PHP . PHP - -. , . - , , .

, , :

+5

All Articles