grycap / scar

Serverless Container-aware ARchitectures (e.g. Docker in AWS Lambda)
https://scar.readthedocs.io/en/latest/
Apache License 2.0
598 stars 46 forks source link

Is it possible to mount a container using tmpfs? #356

Open WinstonN opened 4 years ago

WinstonN commented 4 years ago

Hello

I want to run a large container - https://hub.docker.com/r/cypress/included - using scar When I run it currently, I get the following output

START RequestId: 4eb05b53-034e-4479-a7f0-464c1c665b0a Version: $LATEST
2020-05-10 02:51:50,773 - supervisor - INFO - Reading storage configuration
2020-05-10 02:51:50,779 - supervisor - WARNING - There is no output defined for this function.
2020-05-10 02:51:50,785 - supervisor - WARNING - There is no storage provider defined for this function.
2020-05-10 02:51:50,785 - supervisor - INFO - SUPERVISOR: Initializing AWS Lambda supervisor
2020-05-10 02:51:50,797 - supervisor - INFO - Found 'LOCAL' input provider
2020-05-10 02:51:50,797 - supervisor - INFO - INPUT_FILE_PATH variable set to '/tmp/tmpq5nc09ep/event-file-87889c53-30bc-487d-a804-935b6826a960'
2020-05-10 02:51:50,920 - supervisor - INFO - Pulling container 'cypress/included:4.5.0' from Docker Hub
Downloading layer: sha256:c7b7d16361e00faca0e9393f3f43923f25ceb1210face87839dfc5de988905c1
Downloading layer: sha256:a3ed95caeb02ffe68cdd9fd84406680ae93d633cb16422d00e8a7c22955b46d4
Downloading layer: sha256:b7a128769df1909f91b589d0a4a2e1c1671aebc047a9f46b4b30dfeb7308ea6a
Downloading layer: sha256:1128949d0793d2435bb1f0640a777f32feee88b71d4fe234121c3cfb345a80c4
Downloading layer: sha256:667692510b7038b74e221f92eb33610e4968b669c8a718378ecb1f78739c3713
Downloading layer: sha256:bed4ecf88e6a7ee9d32994c60892873ab8a3e199abdfbad73488537b1d3d52dd
Downloading layer: sha256:1d2d4c3b9b8defc0aa908c889443a1abd5eaa54686f896c81f722c4a651e257f
Downloading layer: sha256:a3ed95caeb02ffe68cdd9fd84406680ae93d633cb16422d00e8a7c22955b46d4
Downloading layer: sha256:f8cc6faea0919a4adc1005777c318568d220e529844a3e8e60562d8160b2535e
Downloading layer: sha256:a3ed95caeb02ffe68cdd9fd84406680ae93d633cb16422d00e8a7c22955b46d4
Downloading layer: sha256:8436c745d1faf76b67e224bfd1cc380f6b9254ade160556009c35e67915efe39
Downloading layer: sha256:b8bef372f9c0d2e8e0551966b783401e8ade872188b30ab199719219c10d8ffa
Downloading layer: sha256:a3ed95caeb02ffe68cdd9fd84406680ae93d633cb16422d00e8a7c22955b46d4
Downloading layer: sha256:a3ed95caeb02ffe68cdd9fd84406680ae93d633cb16422d00e8a7c22955b46d4
Downloading layer: sha256:8f2ebc40fb9ae8ba2beef6ef44e6e466d5cc2435dc20927b022874c329393958
Downloading layer: sha256:b355d55b4c2cf8eb9db788d27060e93a345dbf6e779614745908a5cb4a8bd12c
Downloading layer: sha256:d2c5771a10edd0c908b9b88083944eddb1e72f7d890b88c2b3195c74b26c5808
Downloading layer: sha256:a3ed95caeb02ffe68cdd9fd84406680ae93d633cb16422d00e8a7c22955b46d4
Downloading layer: sha256:a3ed95caeb02ffe68cdd9fd84406680ae93d633cb16422d00e8a7c22955b46d4
Downloading layer: sha256:a3ed95caeb02ffe68cdd9fd84406680ae93d633cb16422d00e8a7c22955b46d4
Downloading layer: sha256:32810a1adcc9796394ef45034f0ba483fbc6902d6dfe332bb4777acacfd251cb
Downloading layer: sha256:a3ed95caeb02ffe68cdd9fd84406680ae93d633cb16422d00e8a7c22955b46d4
Downloading layer: sha256:a3ed95caeb02ffe68cdd9fd84406680ae93d633cb16422d00e8a7c22955b46d4
Downloading layer: sha256:a3ed95caeb02ffe68cdd9fd84406680ae93d633cb16422d00e8a7c22955b46d4
Downloading layer: sha256:309ec77e26aaf56f73a1fce8e4c1e9a715aaa31cbc20e386110acc6ed83d2419
Downloading layer: sha256:4db55be01e45c8470653f11986a3cc36ad4cb816c47dc37fec665397ebf1a156
Downloading layer: sha256:a3ed95caeb02ffe68cdd9fd84406680ae93d633cb16422d00e8a7c22955b46d4
Downloading layer: sha256:e970dae7cfb4d7c26e0a022840c376dd259c57fe59d56e59f889f8bbec3e151f
Error: in download: 
Error: file size mismatch: /tmp/shared/udocker/layers/sha256:e970dae7cfb4d7c26e0a022840c376dd259c57fe59d56e59f889f8bbec3e151f 91104699 -1
Error: no files downloaded
Info: creating repo: /tmp/shared/udocker
2020-05-10 02:52:41,612 - supervisor - INFO - Creating container based on image 'cypress/included:4.5.0'.
Error: create container: imagerepo is invalid
Info: creating repo: /tmp/shared/udocker
Error: invalid container id
Info: creating repo: /tmp/shared/udocker
2020-05-10 02:52:41,850 - supervisor - INFO - Executing udocker container. Timeout set to '238' seconds
2020-05-10 02:52:48,596 - supervisor - INFO - Searching for files to upload in folder '/tmp/tmpqoh8sawt'
2020-05-10 02:52:48,596 - supervisor - INFO - Creating response
END RequestId: 4eb05b53-034e-4479-a7f0-464c1c665b0a
REPORT RequestId: 4eb05b53-034e-4479-a7f0-464c1c665b0a  Duration: 57825.11 ms   Billed Duration: 57900 ms   Memory Size: 3000 MB    Max Memory Used: 605 MB 

I was wondering if we could take advantage of the 3GB max memory of lambda, by using https://docs.docker.com/storage/tmpfs/

Perhaps you know of a better way?

Thank you for the advice

gmolto commented 4 years ago

Hi, We deeply investigated this issue in the past and found absolutely no way to take advantage of this memory for POSIX-type file access. No Ramdisk can be created since /dev/shm is unavailable. The path we took for resource-intensive jobs is the integration with AWS Batch (see https://scar.readthedocs.io/en/latest/batch.html). Not very serverless-ish but at least provides automatic scale-to-zero.

If you come up with any ideas please keep us posted.