On 20/08/13 21:36, Arnold Krille wrote:
On Sat, 17 Aug 2013 03:36:29 +0100 Some Developer
<someukdevelo...@gmail.com> wrote:
I'm aware of django-cron and django-celery, both of which are capable
of doing what I want but I was wondering if I was just making a
fundamental design mistake and there maybe a better option that
someone here could explain.
Basically customers pay money into their account in advance so that
they can use services that we offer. Each service is charged by the
minute and prices between services can vary wildly. I need to be able
to show our clients their current running total to the nearest hour
so that they know when they need to add extra funds to their account.
My initial thought was that I would just have the equivalent of a
cron job running every hour that queries the database for the state
of each users application and then used that to produce an estimate
for their current billing.
Alternately I could get rid of the hourly period task and just work
it out when a customer visits a certain page but that is likely to
lead to long load times and heavy database use.
Any suggestions on what you would do in this situation?
Calculate the value on each visit for now.
Worry about the execution-time when your database actually has lots of
users, payments and service-charges applied and the site does get slow
to load. Then use django-debug-toolbar to see how many queries your are
running to calculate the number and how long these queries take. Try to
reduce the number of queries, do whatever you can in the database
instead of in python.
When you have reached your end of wisdom while optimizing the
algorithm and the sql (or djangos use of sql through the orm), start
looking into celery/cron/django-extensions. While celery _can_ do
regular jobs, its not really its primary use. And probably not worth
setting up celery+redis when you only want it to do cron-jobs. If you
need celery for other stuff already, then use it for cron-jobs too. But
otherwise its probably better to look at the cronjobs-framework of
django-extensions.
Thanks.
I think that is what I will do in the short term to ensure that the
correct data is generated. I'm just not entirely sure how fast this
project will grow so I'll need a longer term plan in place as well
in-case the system is unacceptably slow for users.
--
You received this message because you are subscribed to the Google Groups "Django
users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.