jeudi 13 août 2015

NodeJS - Caching of Dynamic Response

Am facing design issue wherein I want to reduce latency of API Server where it does some heavy processing on requested file based on parameters passed.

This server need to serve processed files to lot of http clients. Note that these dynamic content is result of raw file name and other parameters. At any single point of time it may happen that for many http clients raw file name and other parameters exactly match. So in order to save redundancy this processing has to be done exactly once.

I am currently using Redis based distributed lock to achieve this.

  • What's the better way to avoid this stalling?

Now in order to reduce bandwidth cost; I process these files and upload them to CDN. And eventually pass on the processed-final-URL in redirect request to all interested parties i.e. http clients.

  • How can I make this completely non-blocking?

Based on some reading I found nsq.io can solve this by creating dynamic topic for each unique combination of file and params. But how http clients would consume the result in non-blocking fashion. Note that I do not have any control over HTTP clients i.e. I can't change anything on client side to resolve this.

Aucun commentaire:

Enregistrer un commentaire