DjangoCon Europe 2023 | Squeezing Django performance for 14.9 million users on WhatsApp

"Boost Django's performance for massive user bases, just like WhatsApp, with expert tips for debugging, optimization, and testing, ensuring fast and secure applications with over 14.9 million users."

Key takeaways
  • Use estimating one in 10,000 users saved to measure performance impact
  • Debug Toolbar or connection.queries can help identify slow endpoints
  • Be conservative with estimates, even with relatively small changes
  • Use Faker to generate realistic fake data for testing
  • Use a Postgres configuration option to show slow queries
  • Use Django’s built-in context_processors, like static/media and csrf, to improve performance
  • Create custom pagination class to improve performance
  • Set a timeout on SQL queries to improve performance
  • Use explain analyze to analyze slow queries
  • Test on a separate setup instead of production environment
  • Use log min duration statement to monitor slow queries
  • Be cautious of security when integrating with WhatsApp and Facebook
  • Use Django’s built-in query caching for performance gains
  • Consider using PyPy to get a performance boost
  • Use approximate counts instead of full counts to improve performance
  • Use cursor pagination for large datasets
  • Test with fake users and large traffic volumes
  • Use statistics on the database to improve query performance
  • Use a database that can handle large traffic volumes
  • Use a consultation service to develop and update applications