I recently studied the Tornado web infrastructure to serve many negotiated connections with many different clients.
I have a request handler that basically takes an encrypted RSA string and decrypts it. The decrypted text is an XML string that is processed by the SAX document processor that I wrote. Everything works fine, and the runtime (for an HTTP request) is approximately 100 milliseconds (with decryption and parsing).
XML contains the username and password of the user hash. I want to connect to a MySQL server to make sure that the username matches the password hash provided by the application.
When I add basically the following code:
conn = MySQLdb.connect (host = "192.168.1.12",
user = "<useraccount>",
passwd = "<Password>",
db = "<dbname>")
cursor = conn.cursor()
safe_username = MySQLdb.escape_string(XMLLoginMessage.username)
safe_pass_hash = MySQLdb.escape_string(XMLLoginMessage.pass_hash)
sql = "SELECT * FROM `mrad`.`users` WHERE `username` = '" + safe_username + "' AND `password` = '" + safe_pass_hash + "' LIMIT 1;"
cursor.execute(sql)
cursor.close()
conn.close()
, HTTP-, 4 - 5 ! , , MySql.
: ? MySQL , concurrency - Tornado?
, MySQL- Http, , .
, , SQL , - Tornado
Update
MySQL , .
"connections.py" init 4,944 . ?
2
, ( ) , , - .
1000 , , , .