hpx for web applications #6483
-
Hi everyone! 👋 😄 I am the maintainer of MOTIS which is an open source mobility platform. The focus is door-to-door routing. Our core is based on the RAPTOR algorithm which can be parallelised and we're planning to do this. We're currently using our own custom task library ctx (with Boost context under the hood) which works fine for now but might not be the best option for parallelizing the routing algorithm. Since MOTIS is a web application, it's important to not use all system resources to answer one query. Otherwise, one request that runs a bit longer will block all other user's requests. So my idea was to consider groups of 2 or 4 threads as one "processing unit" that processes a query in parallel. Ideally, those threads of one "processing unit" would be close to each other on the hardware (i.e. share one L2 cache). Then there's a global work stealing queue where these "processing units" get their work from. There needs to be an I/O thread to accept HTTP requests, put them into the queue. After finishing the request, the "processing unit" enqueues the response into the I/O thread so it can be sent back to the client. Another topic is that in our custom ctx library we currently have one global work stealing queue with the option to append at the front of the queue (so it works like a stack, LIFO) or at the back (FIFO). I/O tasks such as new requests coming in via HTTP requests use FIFO but once a task runs, all subsequent tasks spawned by this task are enqueued LIFO so it finishes as fast as possible. Is there something similar in hpx? I guess hpx is primarily used in batch-processing jobs on super computers where these problems do not exist. So my questions are: Does this approach make sense? Is hpx a good fit for this scenario? Can this be done with hpx and if so - how? Is there a best practice on how to connect hpx with a web server? The documentation about HPX runtime and resources looks like it can be done. But maybe not everything at the same time? It looks like I have to chose between LIFO/FIFO for one queue and I can create a thread pool as my "processing unit" but then how do those thread pools steal work from a queue where the web server puts it? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
All of the features you talked about are available in HPX. All of those can be controlled either through the command line or programmatically when initializing HPX:
I'd suggest you join our discord server to discuss things in detail (https://discord.gg/Tn9QuzVjvy). |
Beta Was this translation helpful? Give feedback.
All of the features you talked about are available in HPX. All of those can be controlled either through the command line or programmatically when initializing HPX:
I'd suggest you jo…