FutureSharks / invokust

A wrapper for locust to allow running load tests in python or on AWS Lambda
MIT License
158 stars 42 forks source link

segmentation fault (core dumped) #57

Open jfarr opened 2 years ago

jfarr commented 2 years ago

Hi, I followed the instructions under Running Locust on AWS Lambda but all I get is this error when I run invokr.py:

[2022-01-05 07:33:57,245] LM-C02C775WMD6R/ERROR/invokust.aws_lambda.lambda_load_test: error Unhandled: b'{"errorMessage":"RequestId: bb804730-df31-47d0-bc5f-ac734d0aa70e Error: Runtime exited with error: signal: segmentation fault (core dumped)","errorType":"Runtime.ExitError"}'

Any pointers what I might be doing wrong? I'm building the Lambda package on MacOS Big Sur using these commands:

docker run -it --volume=$PWD:/temp python:3.6 bash -c "pip install /temp --target=/temp/python-packages"
zip -q -r lambda_locust.zip lambda_locust.py locustfile_example.py python-packages
aws lambda create-function --function-name lambda_locust --timeout 300 --runtime python3.6 --role arn:aws:iam::XXXXXX --handler lambda_locust.handler --zip-file fileb://lambda_locust.zip
jfarr commented 2 years ago

FYI after trying many different configurations the only way I could get this to work was as a Lambda container image. Here's the Dockerfile I used for reference:

FROM lambci/lambda:build-python3.6 AS lambda-build

RUN pip install invokust --target /temp/python-packages
COPY lambda_locust.py locustfile.py /temp/python-packages/

FROM public.ecr.aws/lambda/python:3.6

COPY --from=lambda-build /temp/python-packages "${LAMBDA_TASK_ROOT}"

CMD [ "lambda_locust.handler" ]

Then you have push the image to an ECR repository and create the lambda function with:

aws lambda create-function\
   --function-name lambda_locust\
   --package-type Image\
   --code ImageUri=9999999999.dkr.ecr.region-name.amazonaws.com/lambda_locust:latest\
   --role arn:aws:iam::9999999999:role/lambda_basic_execution\
   --timeout 300
FutureSharks commented 2 years ago

the only way I could get this to work was as a Lambda container image

That's annoying!

Any pointers what I might be doing wrong?

I don't have a solution but surely it's just a question of installing the pip packages using the correct docker image. Did you try using public.ecr.aws/lambda/python:3.6? I mean like:

docker run -it --volume=$PWD:/temp public.ecr.aws/lambda/python:3.6 bash -c "pip install /temp --target=/temp/python-packages"
jfarr commented 2 years ago

I don't have a solution but surely it's just a question of installing the pip packages using the correct docker image. Did you try using public.ecr.aws/lambda/python:3.6? I mean like:

docker run -it --volume=$PWD:/temp public.ecr.aws/lambda/python:3.6 bash -c "pip install /temp --target=/temp/python-packages"

That image doesn't have the necessary toolchain.

jfarr1@LMTC-JFARR invokust % docker run -it --volume=$PWD:/temp --entrypoint="" public.ecr.aws/lambda/python:3.6 bash -c "pip install /temp --target=/temp/python-packages"
Unable to find image 'public.ecr.aws/lambda/python:3.6' locally
3.6: Pulling from lambda/python
[...]
generating cffi module 'build/temp.linux-x86_64-3.6/gevent.libuv._corecffi.c'
creating build/temp.linux-x86_64-3.6
Running '(cd  "/tmp/pip-install-mj8r3csr/gevent/deps/libev"  && sh ./configure -C > configure-output.txt )' in /tmp/pip-install-mj8r3csr/gevent
configure: error: in `/tmp/pip-install-mj8r3csr/gevent/deps/libev':
configure: error: no acceptable C compiler found in $PATH
See `config.log' for more details
FutureSharks commented 2 years ago

What if you run the pip install using the lambci/lambda:build-python3.6 image? i.e.

docker run -it --volume=$PWD:/temp lambci/lambda:build-python3.6 bash -c "pip install /temp --target=/temp/python-packages"