Search code examples
google-app-enginedockershared-memoryapp-engine-flexible

How to Change the Size of /dev/shm in App Engine Flexible


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.


Solution

  • 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.