I'm having a hard time getting decent performances with Google Cloud SQL, I'm doing some pretty basic CRUD operations, for instance:
public BaseUser getUser(String token) throws SQLException{
Connection conn = DriverManager.getConnection(JDBC_CON_STRING);
PreparedStatement ps = conn.prepareStatement(GET_USER_BY_TOKEN_QUERY);
ps.setString(1, token);
ResultSet rs = ps.executeQuery();
List<BaseUser> users = inflateUser(rs);
if(users.size() == 0){
return null;
}
if(users.size() > 1){
logger.info("DATABASE MAY BE CORRUPTED, THERE'S MORE THAN 1 USER WITH THE SAME TOKEN");
}
ps.close();
rs.close();
conn.close();
return users.get(0);
}
And getting an average of 450ms reponse time for each query. += 150 for openConnection, 150 for operation, 150 for close. See the img. below.
I've read the google documentation, forums and multiple blogs and still can't see what I'm doing wrong (I must be doing something wrong, 450ms/query is wayyy to much...)
UPDATE 1: I'ts definitively a Google Cloud SQL issue, I installed my own local MySQL server and I'm having way better performances (80ms for an "insert or update", then select finally commit.), hope I could get some hints from Google dev. team, I really like the whole Google cloud platform, but it's simply impossible to work with that level of latency =(
UPDATE 2: 2014/05/06 The latency problem is the same with a D0 or a D16. Trying to insert 10000 rows (3 varchar and a ~100bytes blob) takes 32s from a Google ComputeEngine VM because of the latency. The duration is the same with 10000 inserts and a single batch insert. If I use 64 threads, then the duration is down to 3s. I tested with the native mysql jdbc driver.
Any suggestions? Thanks!