简体   繁体   中英

Python Django Profiling

Problem:

I have a Django application. At the development stage I want to check

  1. The number of users my app can support. These users can be :

    • users stored in the database
    • concurrent users
  2. Find speed improvements, for example chunks of slow code

Tools Used:

I have installed django-debug-toolbar, which shows the Time (CPU) and SQL queries .

What I want:

I specifically want particular graphs or contitative data which can be presented to a large scale audience and on which improvements can be done.

I don't think there's an app for that matter.

You can use apache ab to measure how many requests your app can handle on a givel URL.

ab -c 5 -n 1000 http://yoururlhere.com

See the ab docs for more.

Your "users stored in the database" are limited by your servers hard disk space available, so this should not be a problem.

To find slow code the django toolbar is a good start. If you finde a site that takes long time to load, you can investigate which methods causing this by manually adding:

import logging
def my_slow_code(self):
  start = time.time()
  [slow code]
  logging.debug('my_slow_code took %s s to load' % str(time.time()-start))

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM