We find that mod_wsgi daemon mode works well for us. It won't solve the
template rendering issue, but template structures are cached after their
first parse (the cache is local per-process), so long as DEBUG=False. If
you're seeing this on every page load, it could be due to DEBUG being set
to True (if you're running django_debug_toolbar, this very likely may be
happening), or you're just seeing new threads/processes loading initial
state on first request.

The URLResolver structure does have to be built for each new process as
well, and there's no getting around that, but this is a first-time startup
cost, and users shouldn't be seeing it on-going unless processes are
frequently being re-launched.

You'll also see some slowdown if using a network filesystem to store the
Python packages (rare, but we've seen this happen). Those should always be
local. As should the site directory.

Running daemon mode with a multi-threaded setup should minimize these. Most
of the data will be loaded either immediately on startup or on first
request (per process), and shared amongst all threads. The processes should
rarely recycle as well, as it's mostly the threads that will be discarded
and re-created periodically.

We used to only recommend single-threaded setups before, due to some bugs
in third-party libraries and a couple in ours, but that hasn't been an
issue in a long while. Do we have some stale docs still recommending this
that you saw?

Christian

On Mon, Jan 28, 2019 at 3:13 PM Joshua Cannon <[email protected]> wrote:

> Howdy folks!
>
> My users were complaining about slow performance after we re-provisioned
> our VM from scratch.
>
> After doing some sleuthing using django_debug_toolbar, I found a couple of
> templates were taking a significant amount of time. The first was
> "base/_mobile_navbar.html". After some profiling of rendering the template,
> I found out the time is spent populating the URLResolver's internal data
> structure for all the regular expressions. Every time I refresh the page, I
> see the same template take the same amount of time, which tells me apache
> isn't re-using the processes between requests (or something, I'm not really
> a good sysadmin).
>
> I found that Django recommends deploying using mod_wsgi in daemon mode
> <https://docs.djangoproject.com/en/2.1/howto/deployment/wsgi/modwsgi/#using-mod-wsgi-daemon-mode>.
> But I also noticed our previous incarnation of the server didn't have this
> enabled.
>
> What settings do y'all suggest to ensure each request isn't spending lots
> of time rendering templates? I see y'all recommned using the
> single-threaded Prefork MPM, should I configure WSGI daemon to also be
> single-threaded?
>
> Thanks!
>
> --
> Supercharge your Review Board with Power Pack:
> https://www.reviewboard.org/powerpack/
> Want us to host Review Board for you? Check out RBCommons:
> https://rbcommons.com/
> Happy user? Let us know! https://www.reviewboard.org/users/
> ---
> You received this message because you are subscribed to the Google Groups
> "Review Board Community" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> For more options, visit https://groups.google.com/d/optout.
>


-- 
Christian Hammond
President/CEO of Beanbag <https://www.beanbaginc.com/>
Makers of Review Board <https://www.reviewboard.org/>

-- 
Supercharge your Review Board with Power Pack: 
https://www.reviewboard.org/powerpack/
Want us to host Review Board for you? Check out RBCommons: 
https://rbcommons.com/
Happy user? Let us know! https://www.reviewboard.org/users/
--- 
You received this message because you are subscribed to the Google Groups 
"Review Board Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to