Redis connection within docker container is extremely slow

Viewed 1008

I have a web app in a docker container that connects to a Redis server running in the same docker container. I get around 150ms get and set commands when running this environment in docker (locally and when deployed). When I run the same web app outside of docker, connecting to a Redis server installed on my local machine, I get around 5-10ms timings for most Redis operations, as I should. What on earth could be wrong with my docker container that could cause timings of over 150ms when connecting within the same docker container?

Dockerfile

FROM crystallang/crystal:0.34.0
...
RUN wget http://download.redis.io/redis-stable.tar.gz
RUN tar xvzf redis-stable.tar.gz
WORKDIR /redis-stable
RUN make -j4
RUN cp src/redis-server /usr/local/bin/
RUN cp src/redis-cli /usr/local/bin/
RUN cp utils/redis_init_script /etc/init.d/redis_6379
RUN mkdir -p /var/redis/6379
COPY /redis.conf /etc/redis/6379.conf
RUN update-rc.d redis_6379 defaults
...
EXPOSE 3000
HEALTHCHECK CMD ["/app", "-c", "http://localhost:3000/"]
ENTRYPOINT ["./prod_init.sh"]

prod_init.sh

#!/bin/sh
/etc/init.d/redis_6379 start &
exec [web app startup procedure here]

redis.conf https://gist.github.com/sam0x17/5af8ca142e9eec692d30057160b45d6b

docker stats

CONTAINER ID        NAME                CPU %               MEM USAGE / LIMIT   MEM %               NET I/O             BLOCK I/O           PIDS
06908bd70a00        myapp               0.14%               231MiB / 31.28GiB   0.72%               127kB / 75.9kB      1.11MB / 0B         38
0 Answers
Related