designetwork(EN)

IT technical memo of networking

Relolve Docker Redmine's SMTP delays by asynchronizing

f:id:daichi703n:20180420234858p:plain

Redmine running on Docker response when creating and updating tickets got worse, and as the problem was solved by investigating cause/workaround, write down the procedure.

As a result, by setting the SMTP mail notification to Async (asynchronous), the screen of the ticket will transition without waiting for the completion of mail transmission, and the operation became faster. Although there are some reference articles, since I could not find the information in the Docker environment, I make a note.

Environment

Redmine Docker Image: sameersbn/docker-redmine

github.com

Each parameter is set with this docker-compose-yml.

docker-redmine/docker-compose.yml at master · sameersbn/docker-redmine · GitHub

Problem operation and situation

The outline and situation that I felt as a problem this time are as follows.

  • It takes time to create a ticket (about 30 seconds the tab of the browser wraps around)
  • It takes time to update the ticket (about 30 seconds the tab of the browser wraps around)
  • There are times when it is late and when it is not late
  • Operation such as updating the project setting has no problem at all
  • No load on the server at all

There are several similar cases

Information such as "Redmine ticket update slow" and googling was found.

mussyu1204.myhome.cx

Certainly the behavior that there is no problem in operation was a case where there was no e-mail notification, so I assumed that it corresponds to this case. It should be set to delivery_method: :async_smtp inconfig/configration.yml, but the problem is how to set it in the Docker environment.

SMTP setting in Docker Redmine

Basically, by defining environment variables with docker-compose.yml in the above Docker Image, various settings of Redmine are possible. An example of setting of the part related to SMTP is as follows. (Snippet)

version: '2'

services:
  redmine:
    image: sameersbn/redmine:3.4.4-2
    depends_on:
    - postgresql
    environment:
    #<snip>
    - SMTP_ENABLED=false
    - SMTP_METHOD=smtp
    - SMTP_DOMAIN=www.example.com
    - SMTP_HOST=smtp.gmail.com
    - SMTP_PORT=587
    - SMTP_USER=mailer@example.com
    - SMTP_PASS=password
    - SMTP_STARTTLS=true
    - SMTP_AUTHENTICATION=:login
    #<snip>

In the sameersbn/redmine sample, normal smtp is specified as SMTP_METHOD. In this case, since the completion of mail transmission is waited for in the synchronization process, the response of Redmine 's ticket update screen may be delayed by the sequence of mail transmission.

Change this to async_smtp.

version: '2'

services:
  redmine:
    image: sameersbn/redmine:3.4.4-2
    depends_on:
    - postgresql
    environment:
    #<snip>
    - SMTP_ENABLED=false
-   - SMTP_METHOD=smtp
+   - SMTP_METHOD=async_smtp
    - SMTP_DOMAIN=www.example.com
    - SMTP_HOST=smtp.gmail.com
    - SMTP_PORT=587
    - SMTP_USER=mailer@example.com
    - SMTP_PASS=password
    - SMTP_STARTTLS=true
    - SMTP_AUTHENTICATION=:login
    #<snip>

As a result, the environment variable is expanded and async_smtp is set in the config/configration.yml inside the container as expected. (For clarity, the difference due to async change is described - / +)

$ docker exec -it redmine /bin/bash

root@xxx:/home/redmine/redmine# cat ./config/configuration.yml
# = Redmine configuration file
<snip>
options:
  # http://guides.rubyonrails.org/action_mailer_basics.html#action-mailer-configuration
  email_delivery:
-   delivery_method: :smtp
+   delivery_method: :async_smtp
-   smtp_settings:
+   async_smtp_settings:
      enable_starttls_auto: true
      address: "smtp.gmail.com"
      port: 587
      domain: "www.example.com"
      authentication: :login
      user_name: "mailer@example.com"
      password: "password"
      tls: false

The operation delay of the Redmine has been solved

Changed to async_smtp as described above, problem of delayed response of the operation accompanied by mail sending such as redmine ticket creation/update was solved. However, as set up, a time lag slightly (several seconds to several minutes) has come to occur in mail reception. However, there is no problem compared to the stress of delay of ticket operation. (This is not the case if real-time nature is questioned ...)

Conclusion - Relolve Docker Redmine's SMTP delays by asynchronizing

For Redmine running on Docker, by setting the SMTP mail notification as Async (asynchronous), I was able to cope with the problem of slow response at ticket creation/update.


This Blog is English Version of my JP's.

Sorry if my English sentences are incorrect.

designetwork