title: Is there a way to speed up the authenticate function in django?
body: <p>We're using django to make a json webservice front-end for mysql.  We have apache and django running on an EC2 instance and MySQL running on an RDS instance.  We've started benchmarking performance using apache bench and got some really poor performance numbers.  We also noticed that while running the tests, our apache/django instance goes to 100% cpu usage at very low load and the MySQL instance never gets above 2% cpu usage.</p>
  
  <p>We're trying to make sense of this and isolate the problem, so we did several ab tests:</p>
  
  <ol>
  <li>A request for a static html page from apache -- ~2000 requests/second.</li>
  <li>A request that executes a small python function in django, and no db interaction -- ~1000 requests/second.</li>
  <li>A request that executes one of our django webservice functions that calls authenticate and then does a very simple query to fetch one record from a table -- 11 requests/second</li>
  <li>Same as 3, but commented the call to authenticate -- 95 requests/second.</li>
  </ol>
  
  <p>Why is authenticate so slow? Is it writing data to the db, finding a billion digits of pi, what?</p>
  
  <p>We would like to keep the call to authenticate in these functions, because we don't want to leave them open to anyone that can guess the url, etc.  Has anyone here noticed that authenticate is slow, and can anyone suggest a way to remedy it?</p>
  
  <p>Thank you very much!</p>