OpenSource For You

Queues

-

A simple way to offload work to other processes is to use queues. Yes, these are the same old queues you studied in your college days. As defined on Wikipedia, a queue is a particular kind of abstract data type or collection in which the entities in the collection are kept in order, and the principal ( or only) operations on the collection are the addition of entities to the rear terminal position, and the removal of entities from the front terminal position. nueues are essentiall­y a FirstIn- First- Out ( FIFO) data structure. In our everyday life, queues are used at numerous places to maintain order and efficiency. For example, queues at a ticket counter outside a multiplex are formed to buy tickets on a firstcome- first- serve basis, and to also avoid chaos.

As we have seen, you can reduce the load on Web VHUYHUV Ey RIflRDGLQJ wRUN WR RWhHU SURFHVVHV. )RU example, every request that needs to send an email can add a task in the em~il queue at one end; another process (called the worker process) can pick up tasks one by one from the other end of the em~il queue and do the required work (in our case, sending an email).

If you’re wondering what queues can help you with, the possibilit­ies are endless. A few general cases where they will prove useful are: aata processing that does not directly affect user response. Media processing—e.g., conversion­Lcompressi­on of videos, images, etc; SlideShare or Speakerdec­k converting your presentati­on files into their own format, which the applicatio­n understand­s. rpdating caches— this is an important example. You use caches to quickly send responses for requests that have been previously processed, and by some calculatio­ns, are not different from the previously processed requests. But after some time, the responses in your caches get stale, if the data used gets changed. You generally wait for a cache miss to happen to regenerate the response and update the cache. nueues can help you with updating caches after certain intervals, so that your cache miss rate reduces. As a general rule of thumb, you can use queues for offloading off your server just about anything that does not affect the user response. And if you are doing this, then you are working in the direction of improving the overall user experience.

Newspapers in English

Newspapers from India