Symptoms

After performing the migration procedure from Courier-IMAP to Dovecot described in Linux Mail Hosting Deployment Guide > > Deploying Linux Mail Hosting > Migrating from Courier-IMAP Service to Dovecot IMAP/POP3 Service, average load on the qmail service nodes has sufficiently increased, causing delays in IMAP/POP3 service delivery.

Cause

The full migration procedure from Courier-IMAP to Dovecot gathers Dovecot-specific meta-data on the first login for each mailbox. This takes considerable system resources and may lead to notable performance degradation if several processes are performing simultaneously.

Resolution

Use the below steps in order to perform controllable re-indexing in one thread which will allow you to avoid several indexing processes from running simultaneously (and corresponding load spikes).

For the clustered qmail service:

  1. Add the qmail node to the cluster.
  2. Install "expect" and "tcl" tools on the node:

    #yum install expect tcl
    
  3. Use Linux Mail Hosting Deployment Guide >> Deploying Linux Mail Hosting > Deploying Clustered qmail Service to set up additional qmail node with Dovecot service installed.
  4. Do not configure firewall rules (Linux Mail Hosting Deployment Guide >> Deploying Linux Mail Hosting > Deploying Clustered qmail Service > Creating Load Balancer > Creating Firewall Rules) to avoid distributing requests.

  5. Prepare the list of login/passwords for all mailboxes registered in OA: PostgreSQL 8.x (prior OA 5.3)

    # psql -Uplesk -h`hostname` -At -c "select login,pwd_hash from hs_user_bindings join users using (user_id) join hs_user_services using (user_id ) join identities on (users.auth_identity_id=identities.identity_id) join local_identities on (users.auth_identity_id=local_identities.identity_id) where hs_type='Qmail';"  | awk -F\| '{ printf $1" "; system("/usr/local/pem/bin/encrypt_passwords -f /usr/local/pem/etc/pleskd.props decrypt_passwd "$2) }' > logins.dec``
    

    PostgreSQL 9.x (POA 5.3 and higher)

    # /usr/pgsql-9.0/bin/psql -h `hostname` plesk plesk -At -c "select login,pwd_hash From hs_user_bindings join users using (user_id) join hs_user_services using (user_id ) join identities on (users.auth_identity_id=identities.identity_id) join local_identities on (users.auth_identity_id=local_identities.identity_id) where hs_type='Qmail';" | awk -F\| '{ printf $1" "; system("/usr/local/pem/bin/encrypt_passwords -f /usr/local/pem/etc/pleskd.props decrypt_passwd "$2) }' >logins.dec``
    
  6. Transfer the file logins.dec created in the previous step and the script imap.sh from the attached archive onto the new qmail service node, created on the step 1.

  7. Run the script as follows:`# chmod +x imap.sh

    # awk '{print "./imap2.sh "$1" "$2}' logins.dec | sh -x`
    

Note: Also, you may execute the doveadm fetch -A '"ize.virtual imap.envelope imap.bodystructure hdr.references' all command to build index files for the specified message headers. This gives an additional performance boost to Dovecot. If there is no doveadm utility on your service node, skip this procedure.

For the non-clustered qmail service:

Plan to accomplish the migration procedure during off-peak hours and perform the above mentioned steps starting from step 5.

Note: Also, you may execute the doveadm fetch -A 'size.virtual imap.envelope imap.bodystructure hdr.references' all command to build index files for the specified message headers. This gives an additional performance boost to Dovecot. If there is no doveadmutility on your service node, skip this procedure.

Note: this article is not applicable to OA 5.5 and newer due to passwords policy security changes.

For OA 5.5 and higher, one thing that you can do is the rest part of that KB:

You may execute the "doveadm fetch -A '"ize.virtual imap.envelope imap.bodystructure hdr.references' all" command to build index files for the specified message headers. This gives an additional performance boost to Dovecot.

Internal content

Link on internal Article