Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 709
speedplane Avatar asked Sep 25 '17 21:09

speedplane


People also ask

What is SHM size in Docker?

As seen below. docker run --rm -it -v /dev/shm/:/dev/shm/ --name ubuntu ubuntu. This mapped the local shared memory device to the Docker device. Docker, by default, allows for up to 64 MB of storage space using the shared memory device.

What is Dev SHM?

/dev/shm is a traditional shared memory concept. One program will create a memory portion, which other processes (if permitted) can access. Mounting tmpfs at /dev/shm is handled automatically by systemd. Rationale: Any user can upload and execute files inside the /dev/shm similar to the /tmp partition.

How do I deploy a container in Google App Engine?

Deploy to App Engine flexible environment You can deploy an image hosted by Artifact Registry to App Engine using the Google Cloud CLI. Create the App Engine configuration file for your app. Build a Docker image and push it to your repository. You can use Cloud Build to build and push your container to the repository.


1 Answers

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.

like image 108
posit labs Avatar answered Oct 20 '22 09:10

posit labs