About Features Downloads Getting Started Documentation Events Support GitHub

Love VuFind®? Consider becoming a financial supporter. Your support helps build a better VuFind®!

Site Tools


Warning: This page has not been updated in over over a year and may be outdated or deprecated.
administration:performance

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
administration:performance [2016/04/05 06:24] – [Apache Tuning] powerriegeladministration:performance [2022/05/06 12:52] (current) – [Garbage Collection] demiankatz
Line 4: Line 4:
  
 ====== Java Tuning ====== ====== Java Tuning ======
-After the initial setup and importing of records, you may notice a significant degradation of performance. This means its time to do some JVM tuning. However, if you look around the Internet, you'll quickly realize performance tuning for Java applications is a bit of a black art. However, we'll provide some basic settings to help improve your performance, as well as resources for more in-depth tuning settings.+After the initial setup and importing of records, you may notice a significant degradation of performance. This means it'time to do some JVM tuning. However, if you look around the Internet, you'll quickly realize performance tuning for Java applications is a bit of a black art. However, we'll provide some basic settings to help improve your performance, as well as resources for more in-depth tuning settings.
  
 As a short side-note, these recommendations are for a "server-class" machine with at least 2 GB RAM and 2 processors. There are limits on the architecture that may require editing the sizes provided in the settings. As a short side-note, these recommendations are for a "server-class" machine with at least 2 GB RAM and 2 processors. There are limits on the architecture that may require editing the sizes provided in the settings.
  
-===== JAVA_OPTIONS ===== +===== Setting Options =====
- +
-If you are using the included distribution of Jetty, the tuning options are set in the JAVA_OPTIONS environmental variable. You can either set this for the user running the instance of Jetty (recommended) or in /etc/profile. +
- +
-It's recommended that you run the most recent [[http://java.sun.com | Sun JDK]] as there is an important switch (-server) that you use that is not in the JRE.  +
  
 +:!: This section refers to VuFind 3.x and later. For instructions on earlier releases, see the change history of the page and read an earlier version.
  
 +It's recommended that you run the most recent [[https://openjdk.java.net/|OpenJDK]]. 
  
 ==== Heap Space ==== ==== Heap Space ====
  
-The heap space in Java is the amount of memory allocated to Java for objects. One of the more common issues with a full index of records is an java.lang.OutOfMemoryError exception due to the heap space size. By default, the lower limit is set to 1/64th of the server's physical memory and the max is set at 1/4 the physical memory with a max of 1GB.  +The heap space in Java is the amount of memory allocated to Java for objects. One of the more common issues with a full index of records is an java.lang.OutOfMemoryError exception due to the heap space size. By default, VuFind sets this to 1GB. You can modify this using the SOLR_HEAP environment variable; for example:
- +
-It's a good idea to set both of these to the same value as follows (assumes 4GB of RAM):+
  
 <code> <code>
--Xms3800m -Xmx3800m+SOLR_HEAP=3800M $VUFIND_HOME/solr.sh start
 </code> </code>
  
-Note: For very large indices (> 4 million documents) you will need more than 4GB of RAM, and a 64 bit OS to utilize it.  You must also tell Java to use the 64 bit "memory model" the setting would then look like: +Note: For very large indices (> 4 million documents) you will need more than 4GB of RAM, and a 64 bit OS to utilize it.
- +
-<code> +
--d64 -Xms8192m -Xmx8192m +
-</code> +
- +
-Failure to use the "-d64" flag will result in an error message: +
- "Invalid initial heap size: -Xms8192M +
- The specified size exceeds the maximum representable size. +
- Could not create the Java virtual machine." +
- +
  
 +Please note that simply increasing the heap size to a very large one is not recommended, since it may lead to unnecessarily long garbage collection pauses. With very large heaps there's also a caveat: at 32 GB Java switches to a larger pointer size which means that pointers use up more memory than with lower sizes. Therefore it is suggested to keep the heap at below 32 GB or increase it well past it (see
 +[[https://blog.codecentric.de/en/2014/02/35gb-heap-less-32gb-java-jvm-memory-oddities/|this page]]
 +for more information).
 ==== Garbage Collection ==== ==== Garbage Collection ====
-Garbage collection is how aggressive the JVM is with clearing out unneeded objects. For the purposes of Vufind, parallel garbage collection should work nicely, but read Sun's [[http://java.sun.com/docs/hotspot/gc5.0/gc_tuning_5.html | Tuning Garbage Collection]] for more in-depth information. +:!Since version 5 (included in VuFind 3), Solr has done some garbage collection auto-tuning by default; the suggestions below are probably not necessary for these releases in most situations, and you should probably not tinker with settings unless you have a known problem you are trying to solve.
- +
-<code> +
--XX:+UseParallelGC +
-</code> +
- +
-=== Young Generation === +
-Young generation is a type of garbage collection that has three object spaces, the new object space (Edenand two survivor spaces. Newer objects are created in Edenwhile longer lived objects are moved to the old generation survivor (tenured) spaces. Young generation uses fast copying garbage collection for more frequent clearing of Eden, and more spaced out full garbage collections in the tenured space (which is slower). There are a few switches that will help with this. +
- +
-<code> +
--XX:NewRatio=5 -XX:+UseParNewGC +
-</code>+
  
-Note: if you use the -XX:+UseParNewGC, don't use -XX:+UseParallelGC.+Garbage collection is how aggressive the JVM is with clearing out unneeded objects. You can read the Java manual's [[https://docs.oracle.com/javase/10/gctuning/introduction-garbage-collection-tuning.htm|Tuning Garbage Collection]] section for more in-depth information.
  
 === Collecting Data === === Collecting Data ===
  
-If you want to learn more about your garbage collection performance, you can add the -Xloggc:[filename] parameter to create a log file containing data on Java's behavior.  For example, if you want to store logs in your existing Jetty log folder and use the current date as part of the filename, you could do this:+If you want to learn more about your garbage collection performance, you can add the -Xlog:gc:[filename] parameter to your SOLR_ADDITIONAL_JVM_OPTIONS variable to create a log file containing data on Java's behavior.  For example, if you want to store logs in your existing Jetty log folder and use the current date as part of the filename, you could start Solr like this:
  
 <code> <code>
--Xloggc:$VUFIND_HOME/solr/jetty/logs/gc-`/bin/date +%F-%H-%M`.log+SOLR_ADDITIONAL_JVM_OPTIONS="-Xlog:gc:$VUFIND_HOME/solr/vufind/logs/gc-`/bin/date +%F-%H-%M`.log" ./solr.sh start
 </code> </code>
  
-Once you have a log file, you can use the [[http://www.tagtraum.com/gcviewer.html|gcviewer]] or [[http://www.alphaworks.ibm.com/tech/pmat|PMAT]] tool to get a visual representation of its contents.  This is very helpful in measuring whether your configuration changes have had a positive impact!+Once you have a log file, you can use the [[https://github.com/chewiebug/GCViewer|gcviewer]] tool to get a visual representation of its contents.  This is very helpful in measuring whether your configuration changes have had a positive impact!
  
 +:!: Note that as of VuFind 5.0 (and possibly earlier), the default Solr configuration in VuFind creates a garbage collection log in $VUFIND_HOME/solr/vufind/logs/solr_gc.log, so it may be unnecessary to add extra parameters. However, the example above logs in the specific format expected by GCViewer and shows a way you can control the log filenames, so it is retained as potentially useful for reference.
  
-==== Setting JAVA_OPTIONS ==== +:!Note that in older versions of Java (8 and earlier), -Xlog:gc was called -Xloggc
-For a good base setting for JAVA_OPTIONS, this is a good set to begin with: +==== Setting SOLR_ADDITIONAL_JVM_OPTIONS ====
- +
-<code> +
-JAVA_OPTIONS="-server -Xmx3800m -Xms3800m -XX:+UseParallelGC -XX:+AggressiveOpts -XX:NewRatio=5" +
-</code> +
- +
-For more information on Java Tuning, see [[http://java.sun.com/performance/reference/whitepapers/tuning.html | Java Tuning White Paper]] and experiment with the settings. +
- +
- NOTE: The -server switch needs to be the first argument in the string in order for the JDK to pick up the setting. +
- +
-==== Reminders ==== +
-Be sure to check that the settings are getting applied by running  +
- +
-<code> +
-./vufind.sh check +
-</code> +
- +
-If all went wellyou should see output along the lines of +
- +
-<code> +
-Checking arguments to VuFind:  +
-VUFIND_HOME    =  /usr/local/vufind +
-SOLR_HOME      =  /usr/local/vufind/solr +
-SOLR_DATA_DIR  =  /usr/local/vufind/solr/data +
-JETTY_HOME      /usr/local/vufind/solr/jetty +
-JETTY_LOG      =  /usr/local/vufind/solr/jetty/logs +
-JETTY_CONF       +
-JETTY_RUN      =  /tmp +
-JETTY_PID      =  /tmp/vufind.pid +
-JETTY_CONSOLE  =  /dev/tty +
-JETTY_PORT       +
-CONFIGS        =  /usr/local/vufind/solr/jetty/etc/jetty.xml +
-JAVA_OPTIONS   =  -server -Xmx3800 -Xms3800 -XX:+UseParallelGC -XX:+AggressiveOpts -Dsolr.solr.home=/usr/local/vufind/solr -Dsolr.data.dir=/usr/local/vufind/solr/data -Djetty.logs=/usr/local/vufind/solr/jetty/logs -Djetty.home=/usr/local/vufind/solr/jetty  +
-JAVA            /usr/lib/jvm/java-6-sun/bin/java +
-CLASSPATH        +
-RUN_CMD         /usr/lib/jvm/java-6-sun/bin/java -server -Xmx3800 -Xms3800 -XX:+UseParallelGC -XX:+AggressiveOpts -Dsolr.solr.home=/usr/local/vufind/solr -Dsolr.data.dir=/usr/local/vufind/solr/data -Djetty.logs=/usr/local/vufind/solr/jetty/logs -Djetty.home=/usr/local/vufind/solr/jetty  -jar /usr/local/vufind/solr/jetty/start.jar  /usr/local/vufind/solr/jetty/etc/jetty.xml +
-</code> +
- +
-===== User Contributed Settings ===== +
-William and Mary: Dell Precision 2950, 2x2 dual core Xeon 3.2 GHz processors, 4GB RAM +
-<code> +
-JAVA_OPTIONS="-server -Xmx3800 -Xms3800 -XX:+UseParallelGC -XX:+AggressiveOpts -XX:NewRatio=5" +
-</code>+
  
 +As noted above, if you need to send extra options to your Java startup command line, you can use the SOLR_ADDITIONAL_JVM_OPTIONS environment variable. You can export this to your environment, override it at the beginning of the command line you use to start the solr.sh script, or you can hard-code changes into the solr.sh script, depending on your preferences.
  
 +Best practices for Java tuning have evolved over time and with new releases of Java; try a search for "java tuning" in the search engine of your choice to learn more about current trends.
  
 ===== Resources ===== ===== Resources =====
-Here's a list of useful websites on Java performance tuning:+Here's a list of websites on Java performance tuning; note that some of these are now quite old and may be less relevant to newer JVMs:
  
   * [[http://www.petefreitag.com/articles/gctuning/ | Tuning Garbage Collection Outline]] - older information on the 1.4.2 garbage collection, but still applicable for 1.5+.   * [[http://www.petefreitag.com/articles/gctuning/ | Tuning Garbage Collection Outline]] - older information on the 1.4.2 garbage collection, but still applicable for 1.5+.
Line 125: Line 62:
 ====== PHP Tuning ====== ====== PHP Tuning ======
  
-On PHP 5.4, installing a PHP cache like [[http://pecl.php.net/package/APC|APC]] can significantly improve performance by reducing the amount of time spent by PHP parsing and compiling code. PHP 5.6 comes with build-In OpCache, which is slightly faster than APC. When upgrading, remember to disable the Apache APC module. OpCache should be configured to 64 MB. +On PHP 5.4, installing a PHP cache like [[http://pecl.php.net/package/APC|APC]] can significantly improve performance by reducing the amount of time spent by PHP parsing and compiling code. PHP 5.6 comes with build-In OpCache, which is slightly faster than APC. When upgrading, remember to disable the Apache APC module. OpCache should be configured to 64 MB. 
 +===== Asset Pipeline =====
  
-If you created a custom moduleremember to create a autoloader_classmap.php by calling  +Starting with VuFind 3.1there is an optional "asset pipeline" which can be used to combine Javascript and/or CSS files together to reduce the number of HTTP requests necessary to load VuFind pagesThis is turned off by default but can be activated using the asset_pipeline setting in [[configuration:files:config.ini|config.ini]].
-<code php> +
-../../vendor/zendframework/zendframework/bin/classmap_generator.php -w +
-</code> +
-from module directory+
  
 +===== Theme Compiler =====
  
 +Starting with VuFind 4.1, there is a [[administration:command_line_utilities|command-line tool]] known as the "theme compiler" which can be run to flatten a hierarchy of themes into a single flat theme, reducing the amount of file searching VuFind needs to do in order to find assets and templates.
  
-===== Troubleshooting =====+To use a compiled theme, follow these steps:
  
-There have been some reports of VuFind errors when running APC Excerpt from the vufind-tech mailing list (courtesy of Graham Seaman):+1Run "php $VUFIND_HOME/public/index.php compile theme [your theme] [your compiled theme]" at the command line.
  
-// +2. Update your [[configuration:files:config.ini|config.ini]] file to use [your compiled theme] instead of [your theme] in the theme setting.
-Inserting the line in index.php +
-//+
  
-<code php> +Note: NEVER EDIT THE COMPILED THEME. Instead, edit the source theme and recompile it when you need to make changes. You must use the --force switch of the compiler if you need to overwrite your compiled theme with a new version.
-register_shutdown_function('session_write_close'); +
-</code>+
  
-// +===== Session Handling =====
-immediately before requiring the session handler, seems to fix the problem with APC. Since this is the result of trawling the web and not of any deep understanding on my part, I can't guarantee this won't have sideffects (I'll report back if I find any), or that it will always work. +
-//+
  
-Note: As of VuFind 1.4the default VuFind code will register the shutdown function, so this modification should no longer be necessary.+When using database sessionsdeleting expired sessions may be a surprisingly heavy process. On a busy site it may be beneficial to turn off PHP's session garbage collection (set session.gc_probability to 0 in php.ini) and run VuFind's expire_sessions utility regularly. This makes sure that garbage collection is done outside Apache that serves user requests and with a method that makes it possible to handle session deletion in a large table
  
 ====== Apache Tuning ====== ====== Apache Tuning ======
-For a productive environment, you should always enable GZIP compression. This reduces a amount of data transferred by 70% for text based files like html, js, ... To do so, + 
 +===== GZIP Compression ===== 
 + 
 +For a productive environment, you should always enable GZIP compression using [[https://httpd.apache.org/docs/2.4/mod/mod_deflate.html|mod_deflate]]. This reduces a amount of data transferred by 70% for text based files like html, js, ... To do so, 
  
 <code bash> <code bash>
Line 164: Line 97:
 </code> </code>
  
-One thing you should also do is minifying JS and CSS files. This removes whitespaces and line breaks. It can by done by your IDE. Netbeans for example has a plugin Js CSS Minify Compress. The minified files must be configured in theme.config.php and in some cases in the theme files. Just search for ".js" and replace with ".min.js". If you use LESS to create your CSS files, there is an option --clean-css which optimizes your CSS, too. +Note that the "application/json" type is not usually compressed by default, but turning on GZIP compression for this can significantly approve performance, especially if you use [[indexing:hierarchies_and_collections|hierarchies and collections]]. 
 + 
 +===== Minification ===== 
 + 
 +One thing you should also do is minifying JS and CSS files. This removes whitespaces and line breaks. It can by done by your IDE. Netbeans for example has a plugin Js CSS Minify Compress. The minified files must be configured in theme.config.php and in some cases in the theme files. Just search for ".js" and replace with ".min.js". If you use LESS to create your CSS files, there is an option --clean-css which optimizes your CSS, too
 + 
 +:!: Manual minification should not be necessary if you turn on VuFind's built-in asset pipeline (see above).
 ====== Solr Tuning ====== ====== Solr Tuning ======
  
Line 233: Line 172:
 See the [[configuration:remote_marc_records|Remote MARC Records]] page for details on reducing index size by storing MARC records externally to your Solr index. (Note: requires VuFind 2.5 or newer). See the [[configuration:remote_marc_records|Remote MARC Records]] page for details on reducing index size by storing MARC records externally to your Solr index. (Note: requires VuFind 2.5 or newer).
  
 +===== Limits =====
 +
 +Certain operating system limits can impact Solr performance, and starting with release 7.3.1, the software will warn you if you are below the recommended thresholds. See the [[administration:starting_and_stopping_solr#linux_method|Linux startup instructions]] for notes on how to correct this problem.
 ===== Further Reading ===== ===== Further Reading =====
  
   * [[administration:solr_replication|Solr Replication]] - Basic information about making Solr highly available with replication in the context of VuFind.   * [[administration:solr_replication|Solr Replication]] - Basic information about making Solr highly available with replication in the context of VuFind.
 +  * [[administration:fault_tolerance_and_load_balancing|Fault Tolerance and Load Balancing]] - Fault tolerance and load balancing strategies with VuFind.
   * [[http://wiki.apache.org/solr/SolrPerformanceFactors|Solr Wiki - Performance Factors]] - Pros and cons of various Solr configuration options; also linked to other helpful wiki pages.   * [[http://wiki.apache.org/solr/SolrPerformanceFactors|Solr Wiki - Performance Factors]] - Pros and cons of various Solr configuration options; also linked to other helpful wiki pages.
   * [[http://groups.google.com/group/solrmarc-tech/browse_thread/thread/fe329385bb1dc953|solrmarc-tech indexing time thread]] - A discussion which goes into detail on several significant Solr settings.   * [[http://groups.google.com/group/solrmarc-tech/browse_thread/thread/fe329385bb1dc953|solrmarc-tech indexing time thread]] - A discussion which goes into detail on several significant Solr settings.
Line 248: Line 191:
  
 ---- struct data ---- ---- struct data ----
 +properties.Page Owner : 
 ---- ----
  
administration/performance.1459837477.txt.gz · Last modified: 2016/04/05 06:24 by powerriegel