AppEngine response time is slow - performance

I am using a modified version of the TaskCloud example to try and read/write my own data.
While testing on a a deployed version, I've noticed that the round-trip response time is slow.
From my Android device, I have a 100ms ping response to appspot.com.
I have changed the AppEngine application to do nothing (The Google Dashboard shows insignificant Average Latency.
The problem is that the time it takes for HttpClient client .execute(post) is about 3 seconds.
(This is the time when an instance is already loaded)
Any suggestions would be greatly appreciated.
EDIT: I've watched the video of Google I/O showing the CloudTasks Android-AppEngine app, and you can see that refreshing the list (a single call to AppEngine) takes about 3 seconds as well. The guy is saying something about performance which I didn't fully get (debuggers are running at both ends?)
The video: http://www.youtube.com/watch?v=M7SxNNC429U&feature=related
Time location: 0:46:45
I'll keep investigating...
Thanks for your help so far.
EDIT 2: Back to this issue...
I've used shark packet sniffer to find out what is happening. Some of the time is spent negotiating a SSL connection for each server call. Using http (and ACSID) is faster than https (and SACSID).
new DefaultHttpClient() and new HttpPost() are used for each server call.
EDIT 3:
Looking at the sniffer logs again, there is an almost 2 seconds delay before the actual POST.
I have also found out that the issue exists with Android 2.2 (all versions) but is resolved with Android 2.3
EDIT 4: It's been resolved. Please see my answer below.

It's difficult to answer your question since no detail about your app is provided. Anyway you can try to use appstats tool provided by Google to analyze the bottleneck.

After using the Shark sniffer, I was able to understand the exact issue and I've found the answer in this question.
I have used Liudvikas Bukys's comment and solved the problem using the suggested line:
post.getParams().setBooleanParameter(CoreProtocolPNames.USE_EXPECT_CONTINUE, false);

Often the first call to your GAE app will take longer than subsequent calls. You should make yourself familiar with loading and warm-up requests and how GAE handles instances of your app: http://code.google.com/intl/de-DE/appengine/docs/adminconsole/instances.html
Some things you could also try:
make your app handle more than one request per instance (make sure your app is threadsafe!) http://code.google.com/intl/de-DE/appengine/docs/java/config/appconfig.html#Using_Concurrent_Requests
enable always on feature in app admin (this will cost you)

Related

understanding network tab on chrome console

I'm in the process of writing an app that builds a table of Trello card data based on multiple API calls, and while the app works I'm finding the performance degrades considerably the longer it runs. The initial calls take a couple of seconds while later calls (after 100 runs or so) take upwards of a minute.
Looking at the XHR Network tab on my Chrome console, I can see the bulk of the call is taken by the 'Content Download' phase of the Ajax call. I'm curious as to whether this means the issue is with my application or if the problem resides with the API I'm trying to call? I'm a bit of a novice so my terminology is probably not appropriate here.
The Content Download time is the time during which your content is downloaded from the server.
Very long time can be due to slow connection client-side or server-side.
As you can see TTFB (time to first byte) is about 200ms. So your server is starting sending data after 200ms. Your server process seems to be OK.
You can click on the Explanation link for further information.

SonarQube UI rendering delay (exactly 1 minute!)

I installed SonarQube to help with code quality analysis. I set it up to run behind an Nginx reverse proxy using the instructions on their website. Often I have to wait exactly one minute to load a page. Upon investigation using Google Chrome Developer Tools, I saw that a resource was not loading for exactly one minute. Then, something times out and allows the page to continue to load. Here's a typical example of the problem, where some resources load at the beginning, then there's a one minute delay, then the rest of the page loads:
Sometimes the page loads without any delay.
At first I thought it might be a problem with some JavaScript. Here is an example of clicking around to many pages, and sorting by response time (to see resources might be causing the delay):
I then tried loading a static image, and even that intermittently takes a minute to load.
How can I pin down exactly what component is causing the delay? Could it be the reverse proxy? The SonarQube application? Some JVM problem?
As your 1mn delay happen also with static image (here logo), where there is minimal JVM impact, I would suggest to use curl -L -v against Nginx front end and also directly to SQ HTTP connector.
If 1mn delay never happen when connection to SQ HTTP connector, Nginx / SQ link should be investigated.
If 1mn delay happen also with SQ HTTP connector, SQ JVMs and hosting should be investigated

Optimising Magento Loading Speed - Can't Identify Why Initial Recieving So Slow

While our website is not yet complete graphically and design wise, most of the backend operations are near completion.
However, after optimising the mysql database we are still receiving a significant initial receiving period when tested on pingdom.com:
http://tools.pingdom.com/fpt/#!/IuoBna86v/http://foscam-uk.com
According to Pingdom:
The yellow part is the time it takes to resolve the hostname and similar (before the connection is initiated to the web server), the green part is connecting to the web server, and the blue part is the time it takes to retrieve the content from the webserver.
Upon asking our managed VPS support team we got the response : 'Have you tried optimizing your script? I believe that the high wait time on there indicates actual website loading time (meaning for your script to load); not actual connection to the website/server.'
Now, pingdom shows the js/css loading relatively quickly, the mysql database side of things doesn't seem to be slowing anything down either - does anyone have any suggestions of what this could be or might be causing it?
Thank you very much for your time and help.
89 requests are too many.
Reduce number of image request by creating sprites.This is pretty important from what is shown in pingdom.
Keep Alive should be set to On and Keep alive time should be a bit higher(15 seconds or so).
Use of compiler plus merge and minify js/css is recommended.
Change the hosting provider. 8 second loading is very very slow. It means that it actually is around 15-17 seconds for a user that doesn't have cached parts of your site (first time visitor). My site www.bebepunk.ro loads according to pingdom in 2.5 seconds and users still complain about the slowness of the site. Check also with http://www.webpagetest.org for both values.

Request Timing in `$.ajax` is sometimes above 1 second and sometimes 30ms

I am using xampp version 1.7.7 on windows 7. I am trying to do that when you click save image it would send information to save_record.php in the background. I do this with
$.ajax({
url: 'save_record.php',
data: values.join("&"),
success: function(data) {
//document.write(data);
}
});
And it is clearly not the issue. The problem is that the response is very slow and I am unable to find the reason for it. Below I add the data I received from chrome speed tracer. Firebug is also showing all responses above 1 second. They come in format like 1055ms or 1035ms which makes me think it gets stuck somewhere for one second. If that was not weird enough, it starts making the requests fast (30-50ms) at some time and that is a perfectly usable application for me. Otherwise that 1 second delay is killing it. I once killed process explorer.exe and added as a new task and it worked. But the next time it didn't. I restarted the pc - it is one second... And while I was typing this question it started doing those fast requests. Once it starts doing them fast it's all good, but when I start xampp (or open my laptop from sleep) it is usually slow (1sec+). This is a somewhat self solving problem after some time (like 5-10mins usually), but it is annoying and both curious as why this is happening :) Hopefully I was clear about the problem.
P.S. I tested and the difference in time from first php tag to last one is ~20 ms, so I assume it is not PHP cache that is acting up?
P.S.2. I would provide any other data needed, just not sure what to look at :) Just name it.
UPDATE: added Chrome's network tab.
UPDATE: after reinstallation of xampp the problem still persists:
Uncommenting the line 127.0.0.1 localhost in C:\Windows\System32\drivers\etc\hosts solved the problem. The speed just jumped up incredibly. I found this advice in here. Actually even the speed of Chrome opening other pages increased a lot o.O
Can you take a screen shot of network > Timing tab of chrome developer tool for the request which takes more than a second and share it. For eg.
You must analyze the time taken for each action mentioned in that tab. And also check the event trace from the speed tracer to get more information.
Try changing the content of save_record.php to <?php die(); ?> and see what happens. I suspect it's some kind of delay in processing the save_record operation on the server-side (could be DB is the bottleneck, could be file I/O, etc).
save_record.php ,
what code have you written if you doing any database operation may the operation is taking to much time can you provide me the code of "save_record.php" the i can able to optimize response or can able solve your query

Why are my basic Heroku apps taking two seconds to load?

I created two very simple Heroku apps to test out the service, but it's often taking several seconds to load the page when I first visit them:
Cropify - Basic Sinatra App (on github)
Textile2HTML - Even more basic Sinatra App (on github)
All I did was create a simple Sinatra app and deploy it. I haven't done anything to mess with or test the Heroku servers. What can I do to improve response time? It's very slow right now and I'm not sure where to start. The code for the projects are on github if that helps.
If your application is unused for a while it gets unloaded (from the server memory).
On the first hit it gets loaded and stays loaded until some time passes without anyone accessing it.
This is done to save server resources. If no one uses your app why keep resources busy and not let someone who really needs use them ?
If your app has a lot of continous traffic it will never be unloaded.
There is an official note about this.
You might also want to investigate the caching options you have on Heroku w/ Varnish and Memcached. These are persisted independent of the dynos.
For example, if you have an unchanging homepage, you can cache that for extended periods in Varnish by adding Cache-Control headers to the response. Then your users won't experience the load hit until they want to "do something" rather than when they arrive.
You should check out Tom Robinson's answer to "Scalability: How Does Heroku Work?" on Quora: http://www.quora.com/Scalability/How-does-Heroku-work
Heroku divides up server resources among many different customers/applications. Your app is allotted blocks of computing power. Heroku partitions based on resource demand. When you have a popular application that demands more power, you can pay for more 'dynos' (application containers) and then get a larger chunk of the pie in return.
In your case though, you are running a free app that few people--if any outside of you--are visiting/using. Therefore, Heroku cuts down on the resources you're getting by unloading your app--putting it in hibernation essentially--until there is a request made to your address. When that happens, and your app has been idling for a long time, it takes time to reload.
Add 1 extra dyno to keep your app from falling asleep, if that reload time is important.
I am having the same problem. I deployed a Rails 3 (1.9.2) app last night and it's slow. I know that 1.9.2/Rails 3 is in BETA on Heroku but the support ticket said it should be fine using some instructions they sent me.
I understand that the first request after a long time takes the longest. Makes sense. But simply loading pages that don't even connect to a DB taking 10 seconds sometimes is pretty bad.
Anyway, you might want to try what I'm going to do. That is profile my app and see how long it takes locally. If it's taking 400ms then something is wrong. But if I get 50ms locally and it still takes 10 seconds on Heroku then something is definitely wrong.
Obviously, caching helps but you only get 5MB for free and once again, with ONE person using the site, it shouldn't be that slow.
I had the same problem with every app I have put on via heroku's free account. Now there are options of adding dynos so that your app does not get offloaded while it is not being used for a while, you can also try using redis or memcached for caching. But I used a hacky solution for my small scale project, I basically built web scraper put it inside an infinite loop with sleep and tada the website actually had much better response times(I guess it was not getting offloaded because of the script).

Resources