On 30 Jan 2015 17:13, "Tobias Dacoir" <falc...@gmail.com> wrote:
>
> I just added django-badges to my project. Basically it can award Badges
if Users fullfill certain requirements. For this, everytime I call
user.save() django-badges receives the post_save() signal and starts
checking.
>
> Now my project is similar to an online quiz, where users submit forms to
answer questions. Right now I only have tested it locally and I'm not sure
how to simulate multiple users accessing the page at the same time.
>
> When later run on production in combination with a webserver, will Django
spawn a new thread for each connection / user? Or will there be only one
thread, so if two users are accessing the website, the 2nd has to wait
until the request from the first user is processed?
>

Django is single threaded but the web server can create multiple instances
of your application.

> Also what about my signal to process the badges. If I have a function
that calls user.save(), which then signals to the badges module, will the
execution of the original function stop until the signal has been processed
or not?
>
> def myView(request):
>    do_something()
>    request.user.save()
>    # signal emitted
>    # ...
>    render(view)
>
> So in this case, will the view be rendered immediately or only after the
receiver for the signal has finished doing it's work? In my case I don't
really need it to be asynchronous as long as the badge checking is fast
enough and doesn't block the website for other users.
>

The view will return after the receiver has finished its work. But are you
doing any slow queries? I ask because you might be over engineering your
work.

A good place to start is to benchmark your queries using a tool like
django-debug-toolbar. With that you can know exactly how long it takes one
user to query your database and then use that to estimate for more 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.
> To view this discussion on the web visit
https://groups.google.com/d/msgid/django-users/f3b2f9dd-4681-48a1-8d49-79f73d45d0eb%40googlegroups.com
.
> For more options, visit https://groups.google.com/d/optout.

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CA%2BWjgXPiaV7iFGnFZRiQCNBv_hNypGO%2BewyOxHkLcfOfQ-Vjtw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to