Anything connected to internet has the probability of accessing its resources from anywhere at any given time from any number of users.
As the "any number of users" translates to the number of users can be from 1 to billion at any given time.
Arises the question of, how we are going to allocate resources accessible by the users of any number?
So any number of user can be accessing resources at any time, says clearly the need arises dynamically.
So lets say we can dynamically increase our resources at any time.
A fictious controller that is responsible for increasing the resource pool as per the load.
Consider every call towards the system as Event.
Each Event can be processed by Network of Stages.
Why Events should be processed by "Network of Stages"?
- A Socket connection Event is established with the server and request is read from Socket
- The HTTP request packet is parsed in HTTP parser
- If the requested data by the HTTP request Event is available in Cache, then Cache hit and proceeds to send response by writing the data to the Socket
- If the requested data by the HTTP request is not available in Cache, then Cache miss, now handle Cache miss by doing an I/O Event to the Database to fetch the Cache missed Data back to system, now system sends data by writing the data to the Socket
The above 4 steps are general, which is why Events are processed in stages.
- Socket IN
- Data Parser
- Database (File I/O)
- Socket OUT
as each stage handles their very own Events, each stages will have a Event Queue, Event Handler and Resource Pool Controller
- Event Queue holds events
- Event Handler manages the events by doing enqueue and dequeue operations on the Event Queue
- Resource Pool Controller will allocate the resources like CPU, Network I/O, Memory required by Each Stage Figure 2: SEDA Stage
- Thread pool controller
- Batching controller
As the name suggest the Thread pool controller controls the amount of threads running in the pool.
While the Batch controller controls the number of events processed by Event handlers on their each iterations
Hope you guys find usefull