-
Notifications
You must be signed in to change notification settings - Fork 7
Description
This should be done on the adapter level. @brodock suggests implementing EventMachine support for the ordinary git adapter:
The idea of introducing eventmachine to the IO part of the code, is to be able to do more non blocking operations, which will improve the amount of connections grack can handle.
Thin uses eventmachine already, which should be the most plug an play implementation for this specific case, but it doesn't handle blocking operations automatically, and any blocking IO you make during a request will block the main thread, see: http://stackoverflow.com/questions/19738489/does-thin-block-main-thread-when-doing-io
When you use thin and eventmachine for IO operations together, you can get the best amount of concurrency, that's even better than puma with real threads.
As a simple example, imagine you have 100 clients trying to get files, but 20 of them are requesting from a high latency connection (3G mobile). And the other 80 are on high speed fiber optic connection.
The ones on high latency will block the connection code for a lot longer than the others with fiber, and because of that, everybody will be slowed down.
In an evented environment, the IO part of the code will be resumed in a high frequency by the fibers one, and in a low frequency by the 3G mobile clients, but speed, from the perspective of server load/work, will be the same for both, or in other words, will be evenly distributed.
While I focused more on the clients accessing a resource (this is mostly handled by thin itself), the other important piece in the puzzle is the resource you are accessing that needs to go to the disk and do IO (git).
While disk can be faster, slow, depending on a lot of factors, when you use evented communications, it's the same principle I've exemplified above. While your code is waiting for the chunck of data, it will be doing other tasks that are being required.
For Java, some other implementation is likely necessary.