App Engine perform very bad when using GCS as temporary storage. Isn't it?

243 views
Skip to first unread message

Shaharia Azam

unread,
Mar 13, 2017, 6:38:12 PM3/13/17
to Google App Engine
My Usecase

Recently I just deployed a very small PHP application that was built with the following resource. I was using App Engine Standard Environment for PHP55

  • PHP Slim Framework
  • Twig as Template Engine
  • MySQL
  • I enabled Twig cache for optimizing it's compilation. And the cache directory was in GCS (gs://mybucket/cache).
  • My application's session storage was Cloud SQL (2nd generation).
  • Application was using Monolog as Logger and log directory was also in GCS (gs://mybucket/log) 
  • All of my static assets were serving from a GCS CDN endpoint (gs://cdn.mydomain.com)
Resource Region:
  • Cloud SQL [asia-east1-a]
  • App Engine Region [ASIA-NORTHEAST1]
  • Twig Cache bucket and Temporary file bucket [ASIA-NORTHEAST1]
  • static files bucket (CDN) - multi-region [primary region: asia-east1-a]
When my application serve, it first look for twig cache file, if there is any template caching, it delivers from cache. Also For every route, I have only 1 monolog log is being created in temp directory. What I demonstrated is that, when most of my temporary storage are on GCS (whether it's on same App engine region or nearest region).. my app latency is much much higher than normal. I understand this because, when I just disabled my tmp file and twig cache, then my application serve like a charm. :)

So obviously, I came to a conclusion that when your App Engine will deal with GCS as it's writable file location, you have to fight with it for optimizing your app deliverability.

But AFAIK, almost all application sometimes needs temporary writable file system (though, app engine's file system is only readable). In this case, how App Engine will optimize apps for those application. Am I correct or missing something that my eyes skipped?

George (Cloud Platform Support)

unread,
Mar 14, 2017, 2:21:38 PM3/14/17
to Google App Engine

Is there a particular reason why you prefer deploying to GCS instead of the usual standard environment?


Reading and writing to storage is possible at runtime, if needed, as, otherwise, the local file system is not writeable, for reasons related to scalability. Performance, in this case, is not comparable to writing to a local disc. Performance characteristics of reading and writing files to Google Cloud Storage can be quite different from reading and writing to local disk, especially when frequent modifications need to be made to the same file, as detailed in the “Reading and Writing Files” documentation page for PHP.


Services such as logging are offered by the standard environment as well; no need to implement these separately. For caching purposes, using the memcache in the app engine standard environment is free.


You are quite right, application speed may suffer if you employ GCS as cache. It is not meant for such usage. By contrast, there is a free memcache service meant precisely for speedy access. Memcache is generally an order of magnitude faster than Google Cloud Datastore, and so even speedier when compared with GCS. More information may be found on the “Effective memcache” documentation page. Extra details can be read in the “Memcache Overview” article.


To facilitate the usual developers’ workflow, you may consider developing your application locally and using the PHP Development Server. More details on the relevant page.

Reply all
Reply to author
Forward
0 new messages