How to authenticate a user in a RESTful api and get their user id? (Tornado)
I am assuming that your authentication function talks to a database and that each page in you app hits the database one or more times.
With that in mind, you should probably just authenticate each request. Many cloud/web applications have multiple database queries per page and run just fine. So when performance does get to be problem in your app (it probably won't for a long time), you'll likely already have an average of n queries per page where n is greater than 1. You can either work on bringing down that average or work on making those queries faster.
I would like to maintain statelessness but I also don't want to call my login function on each authenticated request.  Would using tornado's secure cookie functionality be feasible for storing the userid in each request for a mobile app?  I'm trying to keep performance in mind, so although basic http authentication would work, I dont want to call a login function on each request to get the users id.