Performance of new gcloud-java API

138 views
Skip to first unread message

Robert Fox

unread,
Feb 17, 2016, 4:19:33 PM2/17/16
to Google App Engine
I'm a Java developer on Googles App Engine platform. Lately I've been using Managed VMs. According to new-ish documentation on Google's site [1]:

As you become more familiar with the Managed VM environment you should use the native features of the Java runtime and the Google Cloud client libraries for Java rather than App Engine SDKs.
I love that the new gcloud-java seems to be a unified API for local/remote usage. But I do have one concern... and that is my question: How does performance compare to the standard App Engine APIs? I get worried with the new REST APIs with their JSON text processing / parsing... I will build a test suite if I have to but I was hoping someone might already know.

These new developments would seem to be a huge win for Compute Engine if the new gcloud-java is performant and can run fully authenticated.

Out of the following services I'm a heavy user of the four in bold.

Datastore
Logging
Memcache
Search
Task Queue
URL Fetch
Users

Nick (Cloud Platform Support)

unread,
Feb 17, 2016, 7:59:19 PM2/17/16
to Google App Engine
It's an interesting question. Obviously empirical testing is best, but one could investigate the source code to make an informed guess as to the efficiency. Really the native App Engine runtime API's benefit from using gRPC, rather than JSON, but I feel that the gcloud-java library will likely also be able to make use of the more efficient gRPC when in a suitable environment, falling back to HTTP JSON REST when necessary. I'll try to update this thread tomorrow with any of my findings from investigating the source of gcloud-java.

Ifen Shih

unread,
May 19, 2016, 7:17:25 AM5/19/16
to Google App Engine
Hi, 
I'm also a Java developer and in Linux platform. I am using the gcloud-java for operating datastore and that is a really good library.
However, the query/insert performance is not good even I don't count the connection time.
From my testing experience, the average time of inserting and query one entity (4 properties) is about 2000~2800ms/200~600ms.
Could you please let me know that is it possible to improve the performance?
or does your team have plan to improve the performance?? Thanks.

Version: 0.2.1
// Initialize
            DatastoreOptions options = DatastoreOptions.builder()
                    .authCredentials(AuthCredentials.createForJson(new FileInputStream(mCertJsonFile)))
                    .projectId(mProjectId).namespace(mNamespace).build();
            mDatastore = options.service();

// [query] start to log time
mDatastore.run(Query.entityQueryBuilder().kind(KIND_NAME).build())
// [query] end to log time => average: 200~600ms

// [insert] start to log time
mDatastore.put(entity)
// [insert] end to log time => average: 2000~2800ms

Nick (Cloud Platform Support)

unread,
May 19, 2016, 6:31:44 PM5/19/16
to Google App Engine
Hey Ifen,

2 to 2.8 seconds for a single entity put sounds like a serious outlier. Are you seeing that kind of timing for each put? Where is your code running - on your own computer, a Compute Engine instance, inside App Engine, a custom runtime in the Flexible Environment? Is the entity very large? These are the first questions which spring to mind in attempting to understand the amount of latency you're seeing.

Cheers,

Nick
Cloud Platform Community Support

Ifen Shih

unread,
May 19, 2016, 11:13:29 PM5/19/16
to Google App Engine, irqvsio maris
Hi, Nick:
We build up a server on AWS and try to insert/query datastore data.
The entity is not large and only insert/query one entity.
Please help to check the following entity (I used these data to test performance).
Thank you for your prompt reply.

Name/ID (String)
name=9c3248df-4e02-447a-8b61-e9ae4ca590ce 

Category (String)
ABC

Code (String)
abcdefg

State (String)
abcdefg_state

UpdateTime (Integer)
1463712981898

Id (String)
91a2b7e3-f981-46ae-902b-d4fb8ed7ef8b

Nick (Cloud Platform Support)

unread,
May 20, 2016, 1:33:34 PM5/20/16
to Google App Engine, irq...@gmail.com
Thanks for the quick response! Could you let us know the app ID so we could take a look at the Datastore statistics? This does indeed seem unexpected. You may wish to use mtr to test the IP route latency between your instance and our servers. You can run wireshark in the instance while a problematic request is being made to determine the remote IP on our network that your instance is communicating with.

Regards,


Nick
Cloud Platform Community Support

Ifen Shih

unread,
May 24, 2016, 12:31:02 AM5/24/16
to Google App Engine, irq...@gmail.com
Hi, Nick:

Sorry, I don't know the appId and only have project Id. 
But I found the first time insertion spent over 2 secs and the second time (or later) insertion spent about 500 ms.
It seems the first time insertion will do some preparations or initial actions.
I am wondering if there is any possible way to do the preparation before insertion so it can save some time.
Thank you for your great help.

PS. I found some people also met the same problem of datastore and it seems a known issue.

PS2. I tried to use multiple thread to insert/query data to speed it up and the result is acceptable.
Reply all
Reply to author
Forward
0 new messages