Search code examples
pythonmemcachedvoting

Best way of storing incremental numbers?


I'm implementing a voting system for a relatively large website and I'm wondering where should I store the vote count. The main problem is that storing them in the main database would put a lot of strain on it, as MySQL isn't very good at handing lots and lots of simple queries.

My best option so far is to use memcached as it seems perfect for this task (very fast and key/value oriented). The only problem with this solution is that memcached is non-persistent and there is no easy way of saving these values.

Is there something that is specifically designed for this task, preferably with a Python back end?


Solution

  • Can you accept some degree of vote loss? If so, you can do a hybrid solution. Every modulo 100 (10, something), update the SQL database with the current memcache value. You can also have a periodic script scan and update if required.