many imap connections issue

Бауыржан Сахариев baurzhansahariev at gmail.com
Tue Jul 5 03:47:13 UTC 2016


I'm using dovecot 2.1.7


I'm trying to connect to dovecot by imap via Java mail api. My approach
described here
<http://stackoverflow.com/questions/37991025/why-iterating-over-all-java-mail-users-folders-very-slow>.
Bill Shannon, author of the Java Mail api recommended me to check carefully
my server side (I have dovecot at server side).

Actually, imap login in loop works but very slow. Each
store.connect(login,password) takes about 1 minute. I tried to increase
mail_max_userip_connections client_limit and process limit but it didn't
help.

My dovecot sometimes performs query, sometimes not! My logs:

Jul 04 18:23:25 auth: Error: pgsql: Query failed, aborting: SELECT
email, 'maildir:/home/mailboxes/maildir/'||maildir as
mail,'/home/mailboxes/home/'||maildir as home, 500 as uid, 500 as gid
FROM users WHERE email = 'test at test.domain.com'
Jul 04 18:23:25 auth: Error:
sql(test at test.domain.com,127.0.0.1,<HGiPY842jgB/AAAB>): User query
failed: ERROR:  permission denied for relation users

My user and password queries:

password_query = SELECT email as user, password FROM users WHERE email = '%u'
user_query = SELECT email as user,
'maildir:/home/mailboxes/maildir/'||maildir as mail,
'/home/mailboxes/home/'||maildir as home, 500 as uid, 500 as gid FROM
users WHERE email = '%u'

My master conf

*Please note, that I'm using same uid!*

service imap-login {
  inet_listener imap {
    #port = 143
  }
  inet_listener imaps {
    #port = 993
    #ssl = yes
  }

  # Number of connections to handle before starting a new process. Typically
  # the only useful values are 0 (unlimited) or 1. 1 is more secure, but 0
  # is faster. <doc/wiki/LoginProcess.txt>
  #service_count = 1

  # Number of processes to always keep waiting for more connections.
  #process_min_avail = 0

  # If you set service_count=0, you probably need to grow this.
  #vsz_limit = $default_vsz_limit
}

service imap {
  # Most of the memory goes to mmap()ing files. You may need to increase this
  # limit if you have huge mailboxes.
  #vsz_limit = $default_vsz_limit

  # Max. number of IMAP processes (connections)
  #process_limit = 1024
}

service auth {

  unix_listener auth-userdb {
    #mode = 0666
    #user =
    #group =
  }

  # Postfix smtp-auth
  #unix_listener /var/spool/postfix/private/auth {
  #  mode = 0666
  #}

  # Auth process is run as this user.
  #user = $default_internal_user
}

service auth-worker {
  # Auth worker process is run as root by default, so that it can access
  # /etc/shadow. If this isn't necessary, the user should be changed to
  # $default_internal_user.
  #user = root
}

I'm sure that long login *reason is poor dovecot config* but some things
are not clear to me and I can't improve it.

   1. Which service are being used when Java connects to dovecot?
   imap-login,imap or auth? My assumption - imap-login. Imap user for dealing
   with folders *after* login, auth is for delivery (my assotioations here
   are postfix,lmtp,lda) =) Is my assumptions about imap-login and other
   services correct?
   2. Which user are being used when I login? One that specified in
   connection code(one of 50K users in loop) or uid(500) user? I suggested
   that only one user and increased mail_max_userip_connections is it correct?
   3. May some troubles in connection (which I showed above) caused by
   mode(0660) bad config in master.cf services?
   4. Almost each loop iteration connects to dovecot in 60 seconds and
   rarely connects in a few milliseconds. Is that fact somehow connected with
   deafult_idle_kill which equlas to 1 mins?


More information about the dovecot mailing list