Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I have built a very simple Function that receives an url (by mean of an api event type) of a QR image in a query string parameter. This images is downloaded to /tmp with a random name and then using Pyzxing for decoding QR and extract contained info to getting back to client in a json response. But the problem is that there is one line in Pyzxing as follow:

(stdout, _) = subprocess.Popen(cmd,
        stdout=subprocess.PIPE,
        universal_newlines=True,
        shell=True).communicate()

cmd is:

java -jar javase-3.4.1-SNAPSHOT-jar-with-dependencies.jar file:///tmp/xxxxx --multi 

The sam application must require Docker in order to install JRE inside container. I just made a few tweaks in Docker file proposed by SAM CLI as follows:

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

RUN yum install -y java-1.8.0-openjdk

COPY requirements.txt ./
RUN python3.8 -m pip install -r requirements.txt

COPY reader.py ./
COPY javase-3.4.1-SNAPSHOT-jar-with-dependencies.jar ./
COPY app.py ./

# Command can be overwritten by providing a different command in the template directly.
CMD ["app.lambda_handler"]

The java -jar execution takes around 20 secs, but locally with sam local start-api it takes 2 seconds at most. I don't know if this is a matter of hardware or a lack of docker warming in production (it does exists any like that in production?).

Appreciating your advice.

Greetings

question from:https://stackoverflow.com/questions/66067939/performance-issues-with-aws-sam-python-function-and-popen-subproccess

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
421 views
Welcome To Ask or Share your Answers For Others

1 Answer

Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...