Hello,
I am hoping someone can shed some light on a
jdbc performance issue for me.
I am working with
Java servlets running in
Tomcat that connect via JDBC to a MySQL database. The Tomcat is running on one server, the database is running on another but are located in the same building on the same network. With this setup, a simple INSERT statement executed by the servlet against the DB runs very fast (1-4ms). If I ping the IP of my DB server from the Tomcat server, similar result (1ms round trip time).
My Problem:
I move the MySQL DB into the cloud. The DB is now located on Amazon Web servers somewhere in Virginia. Tomcat is located in Illinois. Tomcat and the DB are no longer in the same network. Now, when I execute the same query, it takes 400ms for Tomcat in Illinois to run the INSERT query on the DB in Virginia. If I ping the remote DB from the Tomcat server its about the same as the query (400ms) as expected.
My question:
If I have a servlet application that needs to make 5-10 SQL queries to the remote Db, I am looking at 5 seconds for the DB work alone (which is unacceptable), whereas when it was running locally, it was sub-second. Is there any solution for this scenario? I assume I am just dealing with bandwidth and latency limitations but it seems like this would be a problem for many developers. Or is it just understood that TC server and DB should be physically next to each other or in the same network when developing this type of app?
I have run the local setup for a long time and I am toying with the idea of moving the DB remote (not necessarily keeping it on Amazon, just
testing it for now). Seems like it may not be possible if I need to run a few simple queries in under 1-2 seconds based on my tests.
Any insight is appreciated. Thanks!