I'm using Puma and Nginx to run my Rubinius app.
I would like to separate my URL requests.
The first one would be for API requests, the second one for other requests.
I think Puma already makes threading but I want to be sure that web requests won't block a thread what leads to a stop during my API requests. I suppose that if a thread is busy, Puma will create another one but I want to be sure that one is always available for API requests.
My main point here is to "save" a thread for URL requests which are what my users need the most.
As Puma consider each request within separated thread, the only bottleneck here is database access by such threads. Besides that, you cannot guarantee some threads are 'better' than others.
One of possible solutions worth noting here is to deal with it using
nginx. Let's say you app is serving content onhttp://some_host.comandAPIis available withinhttp://some_host.com/api. You can configure yournginxto handle requests forhttp://some_host.comandhttp://some_host.com/apiseparately. In this case you'll need two separate instances ofPumaserver. One for base app and one for api request. What I mean here is when a request comes tohttp://some_host.com, it is handled byPuma Aand when tohttp://some_host.com/api/..., byPuma B.Just remember one thing, you can handle requests by separated instances, but you still have only one database, unless you're caching content. Here comes another question. Do you cache your content? If not, wouldn't it be greater idea to start with caching first?