← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] ~jugmac00/launchpad:add-performance-documentation into launchpad:master

 

Jürgen Gmach has proposed merging ~jugmac00/launchpad:add-performance-documentation into launchpad:master.

Commit message:
[WIP] Add performance documentation

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~jugmac00/launchpad/+git/launchpad/+merge/447112
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of ~jugmac00/launchpad:add-performance-documentation into launchpad:master.
diff --git a/doc/explanation/index.rst b/doc/explanation/index.rst
index 1ca8cb5..49da0ad 100644
--- a/doc/explanation/index.rst
+++ b/doc/explanation/index.rst
@@ -15,4 +15,4 @@ Explanation
    favicon
    charms
    codeimport
-
+   performance
diff --git a/doc/explanation/performance.rst b/doc/explanation/performance.rst
new file mode 100644
index 0000000..578973a
--- /dev/null
+++ b/doc/explanation/performance.rst
@@ -0,0 +1,73 @@
+About Launchpad performance
+===========================
+
+This document provides an overview of techniques and tools that can help
+Launchpad developers running Launchpad more efficiently - faster, and using
+fewer system resources.
+
+Measure, don't guess
+--------------------
+In order to ensure highly performant web services, we need to have a look at
+numbers.
+
+We conduct regular performance checks with Google's
+`PageSpeed Insights <https://pagespeed.web.dev/>`_ for which we currently score
+an excellent 98 out of 100, with intentions to close the last bits.
+
+We also have
+`internal monitoring <https://grafana.admin.canonical.com/d/oIhMaXhMk/launchpad-dash?orgId=1&refresh=5m>`_
+set up with Grafana, where we measure and monitor various metrics.
+
+Timeouts
+--------
+It is important to have sensible timeouts, as otherwise very slow clients could
+block resources for too long, and prevent other clients from connecting.
+
+We use a default of 5 seconds for all page views. This value can be tweaked via
+`feature rules <https://launchpad.net/+feature-rules>`_.
+
+Writing performant Python code
+------------------------------
+As a general guideline, writing clean and modern Python code usually produces
+considerable fast code.
+
+As a base, you need to
+`choose the correct data structure <https://wiki.python.org/moin/TimeComplexity>`_,
+depending on whether you optimize for lookups, appending elements, or similar.
+
+You also need to be aware of the
+`runtime complexity (Big O) <https://towardsdatascience.com/understanding-time-complexity-with-python-examples-2bda6e8158a7>`_
+of your code.
+
+Another way to ensure high performance is to use caches.
+While Launchpad uses caches on various levels, you should be aware of the
+``propertycache`` module, which offers a ``cachedproperty`` decorator.
+For more information please see the documentation at
+https://git.launchpad.net/launchpad/tree/lib/lp/services/doc/propertycache.rst.
+
+It is also recommended to run the latest version of a software, as that one is
+usually the fastest one.
+This applies both to third party Python libraries, and also to the
+`Python interpreter <https://devblogs.microsoft.com/python/python-311-faster-cpython-team/>`_ itself.
+
+
+Delivering payload
+------------------
+We leverage various ways to improve performance on the server side.
+
+Apache is configured to make use of the `gzip` compression.
+
+Also, static files are directly served by the web server, instead of the
+application server, which reduces CPU load and enables more effective caching.
+
+- what do we do with static files?
+- minification -> lookup
+
+
+Further information
+-------------------
+
+- Debugging timeouts [ link to video ]
+- Debugging slow SQL queries [ we either have a video or link to some EXPLAIN documentation ]
+- Writing efficient queries [ ask Colin]
+- `Preserving query count <https://launchpad.readthedocs.io/en/latest/how-to/preserve-query-count.html>`_

Follow ups