title: Concurrency handling in python based webapp
body: <p>I am developing web app on flask, python, sqlalchemy and postgresql.
  My question is here regarding concurrency handling in this app. </p>
  
  <p>How I wrote the app :</p>
  
  <p>I take the example of adding user in database. I post the form and a view is called. I process all the form data and then call add_user(*arg) which uses sqlalchemy code to insert user in database and returns on successful execution and I return the response from the view.</p>
  
  <p>What I assumed:</p>
  
  <p>Ok now I assumed that my web server (which I have not decided yet) will either spawn a thread or a process if two users are trying to signup at the same time and will handle all the concurreny requirements.</p>
  
  <ol>
  <li>Do i need to write threaded code here? By threaded code I mean that before writing I acquire a lock and after write release it.</li>
  <li>I am pretty new to web development and multithreading/multiprocessing programing and would like some guidance on how write web app which can handle concurrency well.</li>
  <li>Writing concurrency handling from start is right or this thought should come when a large number of concurrent users are using the webapp. Even If it should be done later I would like some pointers about it.</li>
  </ol>
  
  <p>Basically I have no idea about concurrency part of webapp development. If you can point to resources from where I can learn more about it would be really helpful.</p>