On May 28, 2007, at 2:27 AM, Alchemist wrote:

>
> I developed my web application in TurboGears 1.0.1 (Python 2.4,
> CherryPy 2.2.1 and SQLAlchemy 0.3.6) and used Postgresql 8.2 as my
> backend.  Also, I am using psycopg2.
>
> I am running stress tests (using tools such as WAPT and Web
> Application Stress Tool) to test the load supported by the web
> application.  When executing the stress tests I am setting 2
> simultaneous threads forcing a few GET requests on the machine
> (server) hosting my web app.
>
> The results I obtained seem very bad:
> 1. the server seems to crash easily when more than 1 thread throws GET
> requests
> 2. SQLAlchemy is missing some sequence (unique) ids and so some
> database INSERTS are failing

there are several key components of SQLAlchemy which are explicitly  
not threadsafe, and in almost all cases are allocated for usage  
within a single thread only (otherwise youd have to implement a  
locking scheme, for which there is generally no reasonable purpose).   
they are:

Session
SessionTransaction
Connection
Transaction
ResultProxy

and of those, the most commonly explicitly-referenced object is  
Session.  A web application will typically want to create a Session  
that is at the very least local to the current thread, and even  
better that is local to the current request being served.  The  
SessionContext extension is provided to make it easier to manage  
Session objects on a thread local basis (or any other kind of  
scope).  Most frameworks built around SA make use of SessionContext  
or similar to acheive this result.  Whether you use SessionContext or  
not, the main thing is to ensure that a Session isnt shared among  
threads.




--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to