> I would like to build an application that uses CAF for concurrency. The app requires a REST API and hundreds or perhaps even thousands of WebSocket listeners. The architecture of what I have in mind is reminiscent of
https://stiffstream.com/en/docs/shrimp-demo.html, which is also built on top of an actor framework. The request comes through a REST API and triggers a CPU-intensive task that depends on data obtained from WebSocket listeners, database, etc.
>
> I am wondering how to fit similar pattern into the CAF model. In particular, I would like to run Asio in a multi-threaded context, with multiple threads serving IO to allow hundreds or thousands of WebSocket connections. Potentially I would also like to use separate thread pool for REST API and WebSocket IO. The networking part is easy enough: create separate IO context for each group of IO tasks and then dedicate some threads to run the first one and some threads to run the other. But how to combine this with CAF to implement processing of all that data?
CAF already has its own thread pool for scheduling actors. I think the simplest model is having one thread pool for parsing HTTP requests and doing I/O and then just sending to CAF actors. CAF then will take take of putting those actors onto available threads. Also, CAF actors have a couple hundred bytes overhead each, so you can spawn *many* of them.