Is it faster if the docker bind mount is readonly?

There is a problem that it becomes slow around the file io? When developing docker on mac, but check if it will be faster if the bind mount is set to readonly. I feel that it will be faster to make it read only somehow

Mount the Larvle code in/app of the container.

FROM centos:centos8

RUN dnf module install -y php:7.4

WORKDIR /app
CMD [ "php", "artisan", "serve", "--port=80", "--host=0.0.0.0" ]

First, mount it normally without the ro option.

$ docker run -it --rm -v ~/Documents/test/docker/volume_test/ro_test:/app -p 8080:80 ro_test

Use ab test for load test. 10 requests for 10 people = 100 requests in total. Handle 2.78 requests per second 36 seconds to process everything

$ ab -n 100 -c 10 http://localhost:8080/
This is ApacheBench, Version 2.3 <$Revision: 1843412 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking localhost (be patient).....done


Server Software:        
Server Hostname:        localhost
Server Port:            8080

Document Path:          /
Document Length:        17473 bytes

Concurrency Level:      10
Time taken for tests:   35.945 seconds
Complete requests:      100
Failed requests:        0
Total transferred:      1861900 bytes
HTML transferred:       1747300 bytes
Requests per second:    2.78 [#/sec](mean)
Time per request:       3594.549 [ms](mean)
Time per request:       359.455 [ms](mean, across all concurrent requests)
Transfer rate:          50.58 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   0.1      0       1
Processing:   380 3392 655.6   3578    3659
Waiting:      379 3391 655.7   3578    3659
Total:        380 3392 655.6   3578    3659

Percentage of the requests served within a certain time (ms)
  50%   3578
  66%   3596
  75%   3609
  80%   3616
  90%   3630
  95%   3642
  98%   3653
  99%   3659
 100%   3659 (longest request)

Mount with readonly

$ docker run -it --rm -v ~/Documents/test/docker/volume_test/ro_test:/app:ro -p 8080:80 ro_test

2.27 requests per second 43 seconds to process everything Well, readonly is slower.

ab -n 100 -c 10 http://localhost:8080/
This is ApacheBench, Version 2.3 <$Revision: 1843412 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking localhost (be patient).....done


Server Software:        
Server Hostname:        localhost
Server Port:            8080

Document Path:          /
Document Length:        519560 bytes

Concurrency Level:      10
Time taken for tests:   43.979 seconds
Complete requests:      100
Failed requests:        0
Non-2xx responses:      100
Total transferred:      51981200 bytes
HTML transferred:       51956000 bytes
Requests per second:    2.27 [#/sec](mean)
Time per request:       4397.921 [ms](mean)
Time per request:       439.792 [ms](mean, across all concurrent requests)
Transfer rate:          1154.25 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   0.1      0       0
Processing:   455 4155 808.2   4374    4487
Waiting:      447 4145 808.2   4362    4478
Total:        455 4155 808.2   4374    4488

Percentage of the requests served within a certain time (ms)
  50%   4374
  66%   4400
  75%   4436
  80%   4444
  90%   4457
  95%   4471
  98%   4483
  99%   4488
 100%   4488 (longest request)

When it is readonly, an error occurs when trying to write under storage and it takes extra time ...? Try removing ro only below storage.

It seems that it can be overwritten by adding -v later when mounting.

$ docker run -it --rm -v $(pwd)/ro_test:/app:ro -v $(pwd)/ro_test/storage:/app/storage -p 8080:80 ro_test

ab test Handles 2.73 requests per second 36 seconds to process everything And it became almost the same as the state without ro.

ab -n 100 -c 10 http://localhost:8080/
This is ApacheBench, Version 2.3 <$Revision: 1843412 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking localhost (be patient).....done


Server Software:        
Server Hostname:        localhost
Server Port:            8080

Document Path:          /
Document Length:        17473 bytes

Concurrency Level:      10
Time taken for tests:   36.620 seconds
Complete requests:      100
Failed requests:        0
Total transferred:      1861900 bytes
HTML transferred:       1747300 bytes
Requests per second:    2.73 [#/sec](mean)
Time per request:       3661.974 [ms](mean)
Time per request:       366.197 [ms](mean, across all concurrent requests)
Transfer rate:          49.65 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   0.0      0       0
Processing:   370 3461 688.7   3613    4053
Waiting:      369 3461 688.8   3613    4053
Total:        370 3461 688.7   3613    4054

Percentage of the requests served within a certain time (ms)
  50%   3613
  66%   3629
  75%   3640
  80%   3644
  90%   4031
  95%   4044
  98%   4050
  99%   4054
 100%   4054 (longest request)

From this, it seems that it will not be faster even if ro is attached.

Recommended Posts

Is it faster if the docker bind mount is readonly?
It doesn't work if the Map key is an array
Isn't it reflected even if the content is updated in Rails?
Memo: [Java] If a file is in the monitored directory, process it.
Get the type of an array element to determine if it is an array
What is Docker? What purpose is it used for?
If you get the error The data ca n’t be read because it is missing in docker for mac
If the parameter is an array, how to include it in Stopara's params.permit
Docker mount volume permission is managed with fixuid
The end of catastrophic programming # 03 "Comparison of integers, if" a> b ", assume that it is" a --b> 0 ""
[Rails] N + 1 is evil! If it does occur, resolve it for the time being! !! Is dangerous