ipkn / crow

Crow is very fast and easy to use C++ micro web framework (inspired by Python Flask)
BSD 3-Clause "New" or "Revised" License
7.43k stars 889 forks source link

Multi process #400

Open rj314 opened 2 years ago

rj314 commented 2 years ago

I know Crow server supports multi-threading. However, the legacy code base that I would like to use Crow with is not thread-safe. Given that, I am wondering how difficult it is to add multi-process capability to Crow (instead of creating a new thread for each incoming request, fork a new process).

The-EDev commented 2 years ago

Hello @rj314. I'll start off by mentioning that this repository has been abandoned for about 4 years now, I suggest you use this repository instead.

With that being said. Crow does not create a new thread per request. it starts with an acceptor thread and a number of worker threads. each worker thread is then assigned a number of incoming connections by the acceptor thread in a round-robin way. Each thread has its own asio::io_context which is used to manage the connections assigned to it. I'm not sure how you can transform this to multiple processes, but most (if not all) of your changes would be inside the crow::server class.