Skip to content

Long-running tasks blocking the WebSocket process #1058

Open
@ghost

Description

Until recently, we had implemented our chess functionality on two different servers: The WebSocket server and the web server. The former was intended to run real-time tasks while the latter hosted a REST-like API for long-running tasks like database queries, ad hoc reportings, and so on, which would take a few seconds to run.

This separation of concerns was perfeclty fine.

However, at some point it was decided to get rid of the web server and try out an implementation completely based on WebSockets. All functionality, which is to say real-time operations and long-running operations, was moved to the WebSocket server. The reason being was mainly because this setup looked simpler and cheaper.

The thing is, whether using Workerman or Ratchet, the staging server has demonstrated that there is something wrong with this setup.

If two users are playing chess online (real-time) while another user is generating an ad hoc report (long-running) the two users playing online will experience a bottleneck because the report generation seems to be blocking the WebScocket process for a few seconds.

The current WebSocket server is pretty much unusable if there are a few users connected at the same time:

Are we missing something?

Could you please provide some guidance on how to implement long-running tasks with WebSockets? Or should we get back to the previous API implementation for the long-running tasks?

🙏 Thank you for the help, it is very much appreciated!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions