A scenario where I have used Selector
and IO multiplexing
is :
We have a primary content server and 100 secondary content servers. The secondary servers send changed content meta information so that primary will have all the latest content information updated. Initially the design was use 100 threads for the 100 opened sockets which are one to one mapped to secondary servers. But as we want to support more secondary servers, I changed the design to use Selectors
so that one thread does the IO multiplexing (selector.select()
) and send the SelectionKey
to the worker threadPool (Fixed thread pool of size 50). The happiest part is the design worked.
After implementing this couple of questions came to my mind is:
if the secondary content servers had bombarded 100/1000s of requests in a second does this design would have worked (currently we get 5 to 7 requests per second per secondary content server)? Because I feel the above design is nothing but pushing your problem to one more layer down but the problem is still there. Am I correct?
The above design just solves the problem of scaling the no of secondary servers from 100 to 500 but it will not solve the issue if i want to scale the request per second i.e. from 5req/sec to suppose 1000 req/sec.