Slow performance with dovecot – mysql – roundcube

This drove me crazy forever, and Google wasn’t too helpful.  If you’re running dovecot with mysql authentication, your logins will be exceedingly slow.  This isn’t much of a problem with traditional mail clients – just an annoying bit of a hiccup you probably won’t even notice except for SASL authentication when sending mail – but it makes Roundcube webmail PAINFULLY painfully slow in a VERY obvious way.

The issue is due to PAM authentication being enabled by default in Dovecot, and on Ubuntu at least, it’s done in a really hidden little out-of-the-way file with no easy way to forcibly override it elsewhere that I’m aware of.

Again on Ubuntu, you’ll find the file in question at /etc/dovecot/conf.d/auth-system.conf.ext, and the relevant block should be commented out COMPLETELY, like this:

# PAM authentication. Preferred nowadays by most systems.
# PAM is typically used with either userdb passwd or userdb static.
# REMEMBER: You'll need /etc/pam.d/dovecot file created for PAM
# authentication to actually work. <doc/wiki/PasswordDatabase.PAM.txt>
#passdb {
  # driver = pam
  # [session=yes] [setcred=yes] [failure_show_msg=yes] [max_requests=]
  # [cache_key=] []
  #args = dovecot
#}

Once you’ve done this (and remember, we’re assuming you’re using SQL auth here, and NOT actually USING the PAM!) you’ll auth immediately instead of having to fail PAM and then fall back to SQL auth on every auth request, and things will speed up IMMENSELY. This turns Roundcube from “painfully slow” to “blazing fast”.

Published by

Jim Salter

Mercenary sysadmin, open source advocate, and frotzer of the jim-jam.

17 thoughts on “Slow performance with dovecot – mysql – roundcube”

  1. Alternatively, you can just comment out the line !include auth-system.conf.ext in the file 10-auth.conf. Same effect, but a bit cleaner. Debian 7 here, exim+dovecot(sqlite)+roundcube

  2. Thanks – was just browsing your site and came across this, that’s amazingly helpful

  3. Very useful. This just stopped me going round and round in circles!

    Thank you so much!

  4. Oh. My Word.

    The difference is literally black and white!

    Thank you SO much.

    I have added it to my wiki as well.

  5. Just had to say, this was so hard to find but this was the solution! I can’t believe this isn’t mentioned in any tutorial.

  6. Great Advise Jim, speed up my roundcube+dovecot with my Lemp system up very good. Tqvm

  7. Great googly moogly… This is great… I’ve been troubleshooting slow issues with my dovecot server on ubuntu 18.04 forever (at least two months off and on) and never found the right google search terms to stumble across this article until today!…

  8. Hello from 2020. You saved my day!!! Fresh installation of Roundcude with one email in mailbox was taking seconds to show inbox screen. My brain was boiling…. Thanks!!!!

  9. Muchísimas gracias, fue de gran ayuda tu publicación, me ayudó a resolver la lentitud en dovecot.

  10. I just into this issue and this helped me track it down, thanks so much.

    One thing I’ll add is that I have a system that is doing both PAM authentication and SQL authentication, so just commenting out PAM wouldn’t work for me. You can order the lines in 10-auth.conf like this to just make it try SQL first:

    !include auth-sql.conf.ext
    !include auth-system.conf.ext

    But that alone might not be enough, because the processes for authenticating users and looking up their mail directories is separate; if you have a static userdb configuration for your SQL users, then after a user authenticates with PAM, it may end up returning the wrong mail directory for them. I fixed that by switching the userdb configuration for SQL users to use a sql query, then wrote a query that returns no results if it searches for a system user.

Leave a Reply

Your email address will not be published. Required fields are marked *