I have a simple NodeJS app on top of ElasticSearch (which runs on a separate machine). When I start the app using pm2 and sequentially do some random requests, performance is fine. However, when I Dockerize the app, about one in ten responses is very slow (about 5 seconds instead of 50 ms).
This is my pm2 config:
{
"apps": [
{
"name": "api",
"script": "./app/server.js",
"merge_logs": true,
"max_restarts": 20,
"instances": 1,
"max_memory_restart": "1G",
"env": {
"PORT": 5000,
"NODE_ENV": "production"
}
}
]
}
And this is the Dockerfile:
FROM alpine:3.6
ENV srcdir /src
RUN mkdir ${srcdir}
WORKDIR ${srcdir}
RUN apk add --update nodejs nodejs-npm && npm install npm@latest -g
ADD package.json ${srcdir}
RUN npm install --production
RUN npm install -g pm2
ADD . ${srcdir}
EXPOSE 5000
CMD pm2 start --no-daemon processes.json
via user3170702
No comments:
Post a Comment