Event Driven Systems - Mystery!

I was just discussing the event driven systems. The systems in domain were those which communicate frequently with servers, i.e. request and response arch. How exactly event-driven arch. helps, and why do we need them? Why event-driven systems are more robust towards load, and high peaks?

Most of such systems are synchronous. For example, server may fetch and send email data to requestors who provide name to the server. If requestors become large in number, the ‘load’ picture starts building.  Depending upon the bandwidth of wire, processor capabilities and database communication speed (and others), the server response to load is calculated (since we are on server side, lets avoid client/requestor constraints). That basically indicates the strength of server to respond to number of responses in a given period.

This strength can definitely be increased by increasing any of those three parameters.

However, if a deep look inside the way server receives requests and sends responses, a different perspective for increasing efficiency can be looked at.

Lets take an example of chat over web. Sending a message is easy, all is needed is to type message and click send button. How does chat window receives a message? It keeps asking the server for any message headed for his username. Server sends a message if its there, else null. Assuming chat client asks server for new message every second and there are 100 such chat clients, the load on server is 100/sec. If the capacity of server is 100/sec as well, and 10 new users log in and open chat clients, atleast 10 of them will receive message after 1 sec period. Load conditioning talks about handing these loads by the system. One way, as I proposed would be increasing processor numbers/speeds, data-width or database response etc. This is also called synchronous communication. Mind you, even if there is no message for next 10 sec, client still pings server every sec. So, the load is almost independent of actual message exchanges.

Lets talk the other way, the event driven way. This says a client asks server for new message only if a new message has arrived (lets not get into how does this mystery happens!). The arrival of a new message is called an event. Alternatively, server sends a message to client whenever a new message arrives (lets not get into how does this mystery happens!) meant for it. The client contains a listener from server, which receives message and displays it. This way, firstly, the load of listening continuously has been transferred to client side, avoiding that load on server. Secondly, this is an asynchronous approach to the same problem if u didn’t realize. The amount of server-processing or number of server responses is order of that of actual messages. In other words, server sends only 10 or 20 messages for 100 chat clients instead of 100. This is because on average only 10 % (a rough estimate) of users sends message in a particular period of second. That’s quite a good achievement!

Event driven systems are completely asynchronous and load-conditioning systems. System operates only if an event/set of events occur. This helps utilizing capacity of server to full strength.

Lets not get into the mystery here!

No comments:

Post a Comment