5

How do you change the size of the shared memory folder /dev/shm in an App Engine Flexible app?

By default it is set to 64M, too low to run many apps (e.g., chrome). I don't see any way to change it. There are ways to change it if you have access to the docker run command, but we don't have such access when launching app engine flexible apps.

speedplane
  • 15,673
  • 16
  • 86
  • 138
  • You should query google support also for this. The documentation around customization is not available much – Tarun Lalwani Sep 26 '17 at 06:17
  • So it's not the same thing but you can create tmpfs volumes if that helps. https://cloud.google.com/appengine/docs/flexible/nodejs/configuring-your-app-with-app-yaml#resource-settings – Zach Fewtrell Sep 26 '17 at 15:15
  • @ZachFewtrell that would help if you were able to mount to /dev/shm. I tried and it doesn't work. – posit labs Sep 26 '17 at 19:48

2 Answers2

3

A: No.

Unfortunately this isn't possible (yet?) with appengine. More than a few people have run into this issue. For some reason, the container default for /dev/shm is crazy small.

...but there are other options

If the process you want to run has the ability to configure the location of the tmpfs it uses, then you can create a tmpfs and simply point it there. Chromium can't do this.

Option 1

If you want to deploy a container to google cloud, one option is to use container engine. You can then mount a tmpfs volume to your pods like this:

spec:
  volumes:
  - name: dshm
    emptyDir:
      medium: Memory
  containers:
  - image: gcr.io/project/image
    volumeMounts:
      - mountPath: /dev/shm
        name: dshm

Kubernetes has a fairly steep learning curve, but it will allow you to uncap the limit on /dev/shm.

Option 2

There is a new feature that will allow you to deploy containers to compute engine, but it's currently in alpha and you will need to apply to have your project whitelisted to use this feature.

Option 3

Of course, you could deploy containers to GCE in a more manual fashion by creating a GCE instance using COS (container optimized os)


Update from speedplane's comment

Option #4

If the goal is to run a full browser on app engine flexible, then the new versions of Firefox run in headless just fine in Docker.

posit labs
  • 8,951
  • 4
  • 36
  • 66
  • 1
    I would add option #4 (which is what I went with)... if the goal is to run a full browser on app engine flexible, then the new versions of Firefox run in headless just fine in Docker. – speedplane Oct 02 '17 at 19:50
  • I will also add, that after upgrading to a newer version of Firefox, I started running into this issue. Maybe the newer versions use more shared memory? The versions that work for me are Firefox 56.0.2 and Geckodriver v0.19.1. – speedplane Feb 27 '20 at 03:35
2

This is the answer I received from Google Support (support ID 13757624):

I understand that you have inquiry if it would be possible to increase the size of /dev/shm in App Engine Flex.

Unfortunately, this isn't possible. Since Flex is managed VM the default value is maintained. You may try to create manually a command on your dockerfile to change the shared cache via 'sudo' but there's no guarantee so I can't say that it will possibly work, still worth a try given that you are using custom runtimes otherwise, there's no other way.

speedplane
  • 15,673
  • 16
  • 86
  • 138