Alfresco Tuning Shortlist

During last few years, I have seen dozens of Alfresco installations in production without any kind of tuning. That makes me thing that 1) nobody cares about performance or 2) nobody cares  about documentation or 3) both of them!
I know people prefer to read a blog post instead the product official documentation. Since Alfresco have improved A LOT our official documentation and most of the information provided below can be found there, I want to point out some tips that EVERYONE has to take into account before going live with your Alfresco environment. Remember, it’s easy Tuning = Live, No Tuning = Dead.
Tuning the Alfresco side:
  • Increase number of concurrent connections to the DB in alfresco-global.properties
# Number below has to be the maxThreads value + 75
db.pool.max=275
  • Increase number of threads that Tomcat will use in server.xml – section 8080, 8443 and 8009 in case you use AJP
maxThreads=“200”
  • Adjust the amount of memory you want to assign to Alfresco in setenv.sh or ctl.sh (which is the default one):
export CATALINA_OPTS=" -Xmx=16G -Xms=16G"
in JAVA_OPTS make sure you have the flag “-server” that gives 1/3 of memory for new objects, do not use “XX:NewSize=” unless you know what you are doing, Solr takes many new objects and it will need more than 1G in production.
ooo.enabled=false
jodconverter.enabled=true
Tuning the Solr side:
In solrcore.properties for both workspace and archive Spaces Store
alfresco.batch.count=2000
solr.filterCache.size=64
solr.filterCache.initialSize=64
solr.queryResultCache.size=1024
solr.queryResultCache.initialSize=1024
solr.documentCache.size=64
solr.documentCache.initialSize=64
solr.queryResultMaxDocsCached=2000
solr.authorityCache.size=64
solr.authorityCache.initialSize=64
solr.pathCache.size=64
solr.pathCache.initialSize=64
In solrconfig.xml for both workspace and archive Spaces Store 
mergeFactor change it to 25
ramBufferSizeMB change it to 64

April/9/2015 Update! For Solr4 (Alfresco 5.x) add next options to its JVM startup options:

-XX:+UseConcMarkSweepGC -XX:+UseParNewGC
Tuning the DB side:
Max allowed connections, adjust that value to the total amount of your Alfresco or Alfrescos plus 200, consider increase it in case you use that DB for other than only Alfresco.
  • For MySQL in my.cnf configuration file:
innodb_buffer_pool_size = 4GB
max_connections=600
innodb_log_buffer_size=50331648
innodb_log_file_size=31457280
innodb_flush_neighbors=0
  • For Postgres in postgresql.conf configuration file
max_connections = 600
Do maintenance on your DB often. Run ANALYZE or VACCUM (MySQL or Postgres), a DB also needs love!
Tuning the OS side:
I’m not very good on Windows so I will cover only a few tips for Linux:
  • Change limits in /etc/security/limits.conf to the user who is running your app server, for example “tomcat”:
tomcat soft nofile 4096
tomcat hard nofile 65535

If you start Alfresco with a su -c option in /etc/init.d/, for Ubuntu you have to uncomment the pam_limits.so line here /etc/pam.d/su, if this is using login (by ssh) it is uncommented by default. For RedHat/Centos this line has to be uncommented here /etc/pam.d/system-auth.

  • Your storage throughput should be greater than 200 MB/sec and this can be checked by:
# hdparm -t /dev/sda
/dev/sda:
Timing buffered disk reads: 390 MB in  3.00 seconds = 129.85 MB/sec
  • Allow more concurrent requests by editing /etc/sysctl.conf
net.core.somaxconn = 65535
net.ipv4.tcp_max_syn_backlog = 65535
net.ipv4.ip_local_port_range = 2048 64512
net.ipv4.tcp_tw_recycle = 1
net.ipv4.tcp_tw_reuse = 1
net.ipv4.tcp_fin_timeout = 10
Run “sysctl -p” in order to reload changes.
  • A server full reboot is a good preventive measure before going live, it should start all needed services in case of contingency and we will find if we left something back on the configuration.
Remember, this is ONLY A SHORTLIST, you can do much more depending on your use case. Reading the documentation and taking our official training will be helpful and take advantege that we were polishing our training materials lately.

16 thoughts to “Alfresco Tuning Shortlist”

  1. Toni, is there a reason to adjust memory in catalina.sh? Wouldn’t it be better to do this in setenv.sh?

    Append/Adjust memory by including this line in setenv.sh:

    export CATALINA_OPTS=” -Xmx=16G -Xms=16G”

  2. Hi Gi! Thanks for your comment. I totally agree with you, this is a cleaner way to do it. I will improve the blog post with it. Thanks!

  3. Hi Toni and Gi:

    Nice post (as usual). I would say that in the default installer, the “default” JVM options for the heap memory ($JAVA_OPTS) are set in $ALF_HOME/tomcat/scripts/ctl.sh (which is called by alfresco.sh).

    Although it is usual to set java and catalina properties in setenv.sh in Tomcat, I think it is better to set them in ctl.sh, for getting all JVM config in the same place.

    I would say too, maxThreads in Tomcat (7) are 200 by default (in http and ajp).

    Regarding filehandlers, you have to take into account how your java process for tomcat is launched (for example, if su is used in linux init script). Maybe it is necessary to enable user limits (pam_limits.so) for /etc/init.d/su

    Regards.

    –C.

  4. Hi Cesar, thank you very much for your feedback.

    Either way is fine, in most cases it depends on the installation using the installer, using ctl.sh or setenv.sh or any other place where the administrator got control of that.

    On the maxThreads this is a change for Alfresco One 5.0 but it still being a good advice for previous deployments.

    Cesar, could you give me a valid example for /etc/init.d/su configuration file please?

    Cheers.

  5. Hi Toni:

    I’m agree that JVM propeties can be set in both files, but as the default Alfresco JVM config is in ctl.sh I prefer to put it there. If not, you can set heap settings in two diferent files (and twice, and that is a problem). Tomcat admin goes to set up to setenv.sh, instead of ctl.sh (where are defined by default). This is if you append, if you override in setenv.sh, you probably miss other important JVM settings for example, related to JMX.

    I send you a file for Ubuntu 14.04 LTS Server Edition (or 12.04) by mail. Anyway you should check that this file contains the next (by default it is commented):

    # Sets up user limits, please uncomment and read /etc/security/limits.conf
    # to enable this functionality.
    # (Replaces the use of /etc/limits in old login)
    session required pam_limits.so

    –C.

  6. Thanks Cesar, I see, if you start Alfresco with a su -c option in /etc/init.d/, in Ubuntu you have to uncomment the pam_limits.so line here /etc/pam.d/su, if this is using login (by ssh) it is uncommented by default. For RedHat this line has to be uncomented here /etc/pam.d/system-auth.

    Adding this information to the article, I think now is more clear. Thanks!

  7. Right! Depending on how you launch the java process (in a login shell via ssh, via su or sudo in a init script, even via alfresco.sh directly) the security settings for filehandlers are inherited or not. Probably not necessary with with a “Tomcat daemon”. Thanks for the Red Hat feedback.

    –C.

  8. Hi Tony,

    Thanks for this excellent post.

    On ubuntu the max value for servernet.core.somaxconn is 65535 and not 65536

    Stephane

  9. I use to config the swapping management. If there is only one application running in your server(Alfresco), vm.swappiness=1 or 0(No swapping or only in so very special moment). So, server’s memory will be management by JVM (Xms, XMX high).

    Did you check tcp_tw_recycle with high volume of users from different networks (NAT/proxy)?

    Hasta luego

Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.