dimanche 27 mars 2016

Load data aysnchronously using Django REST

I am having a REST service which returns a list of players and their scores. The calculation of score for each user in the list is heavy as it is being done for each request and it involves database interactions. How can I optimize this?

The options which I can think of is -

  1. Cache the score calculation and invalidate cache at certain intervals.

    • How to do this in django-rest-framework elegantly?
    • The cache need be invalidated frequently, maximum 5 mins. (This factor tells me that caching will be too heavy and not so effective)
  2. Load the list of users and send their scores asynchronously.

    • Where will handled by Server & what will be on Client?
    • Will it be like 1 request to load list of 100 users and then 100 requests to get their corresponding scores?

Or you can tell me some other better pattern to follow?

Aucun commentaire:

Enregistrer un commentaire