Download performance of POP vs IMAP
Email protocols
IMAP and POP are protocols for the retrieval of email from a server. The protocols have different approaches for the retrieval of email. POP tends to be faster than IMAP for JEMH’s use case.
When using IMAP, Jira fetches attachments in chunks of just 16 kB by default. This can have a negative impact on performance when downloading large attachments, showing up as FolderClosedException where the mail server closed the connection on JEMH as it reads the mail because it exceeded server limits. POP does not have this issue because the complete email is downloaded in one chunk.
Some system properties can be set within Jira to increase the fetch size for IMAP retrieval. This can result in a significant performance boost when using IMAP to download large emails.
Increasing IMAP fetch size for Jira
The following system properties set the IMAP fetch size for the standard and SSL protocols respectively. Values for the parameters are in bytes. In this example the size of fetched chunks is set to 4Mb (up from the 16 kB default):
-Dmail.imap.fetchsize=4194304 -Dmail.imaps.fetchsize=4194304
Depending how you launch Jira, setting environment variables for Jira can be approached in different ways:
Jira: Setting properties and options on startup
Within a Linux environment this would be added to “JVM_SUPPORT_RECOMMEND_ARGS” on line 14:
Confluence: Configuring System Properties
DC instances
To be clear, the environment settings must be made to every DC node you have.
Verification
Once you have made the changes and restarted your nodes you should see the settings reflected in (Jira specific) Jira > System > System Support > System Info, as shown below:
Javadoc references:
Performance comparisons
The below tests were executed against a basic JEMH profile containing a single default project mapping. A secure IMAP connection was configured in Jira and then bound to a JEMH mail handler. Emails with a single attachment of increasing size were used as test data.
POP
Email size (MB) | Processing Time |
---|---|
5 | 4.9 Seconds |
10 | 7.6 Seconds |
15 | 11.7 Seconds |
20 | 15.1 Seconds |
IMAP (Default Fetch Size of 16Kb)
Email size (MB) | Processing Time |
---|---|
5 | 2.9 Minutes |
10 | 7.1 Minutes |
15 | 10.3 Minutes |
20 | 11.2 Minutes |
IMAP (Fetch Size Set to 4MB )
Email size (MB) | Processing Time |
---|---|
5 | 10.3 Seconds |
10 | 17 Seconds |
15 | 26.3 Seconds |
20 | 35.2 Seconds |
Additional considerations
You can also disable partial fetch so that all email data is retrieved in one go, similar to POP. This is done using the property/value -Dmail.imap.partialfetch=false
. Note that as with all system configuration changes, you should test before using in production environments.