Delivery Queue

I’ve moved onto working on the internals of my web applications queue. I’ve started on it before, but started running into problems with the cron manager. Chris Stephens helped point me in the right direction to work around the problem with a nifty trick.

A queue gives me the ability to save tasks in a database and continue operations. A worker process queries the database every so often and asks if there are any tasks that it can perform. The tasks can occur immediately, or be scheduled to occur in the future. It’s setup in a way that I could actually run a distributed network of computers to pull out a piece of work, do a few operations, and then report back with the results. It definately helps with the future potential of scaling up if my application ever catches some popularity.

The original schema that I had was restricted to specific clients and unque commands for each individual client. It was too tightly coupled and did not offer room to grow and become versitile accross new features in my web application.

I’ve also got a way worked out to find commands that shouldn’t be duplicated in scheduled work to prevent someone from abusing the system with multiple requests to do the same thing. I would have to say that the Queue system is one of the core components that tie the majority of features together. Without it, the current process of web page executions would be far too dependent on resource intensive work and could end up causing more errors then necessary.

It’s best to schedule work to be done and write a response that something will happen eventually, rather than facing the possibility that you’ll have to report an error. In addition, queued work can be attempted multiple times before giving up.

Example – have a page with a button that says “Deliver Product”. When the user clicks submit, I could contact the server before I respond to the user stating if the request succeeded or failed. Instead, I schedule a delivery and tell them they should receive it shortly (or within 2 hours). If the region is down where the drop box is located, I could then attempt to contact another drop box to send it, or wait 5 minutes and try again. See? Bliss and happy customers. No need to refund that money rite away if the region is simply down for a reboot or an upgrade.

posted by Dedric Mauriac on Applewood using a blogHUD : [blogHUD permalink]

Comments are closed.

%d bloggers like this: