5.3 Tuning for Speed
First of all are you slow?
Tuning OSCAR for speed
More or less in order of decreasing return. Take with a grain of salt as you are getting this from a physician, and not a systems operator type.
1) MySQL itself
mysql> SELECT CEILING(Total_InnoDB_Bytes/POWER(1024,3)) RIBPS FROM
(SELECT SUM(data_length+index_length) Total_InnoDB_Bytes
FROM information_schema.tables WHERE engine='InnoDB') A;
+-------+
| RIBPS |
+-------+
| 25 |
+-------+
1 row in set (15.49 sec)
mysql> SELECT @@innodb_buffer_pool_size; +---------------------------+ | @@innodb_buffer_pool_size | +---------------------------+ | 6442450944 | +---------------------------+ 1 row in set (0.00 sec)So you can see 6G are set for innodb_buffer_pool_size which is no where near. Determine in conjunction with the Tomcat's JAVA_OPTS memory setting (see below) and server overhead that you have enough physical memory.
innodb_buffer_pool_size = 8G
apt-get install mysqltuner
General recommendations: Run OPTIMIZE TABLE to defragment tables for better performance Adjust your join queries to always utilize indexes Increase table_cache gradually to avoid file descriptor limits Variables to adjust: query_cache_size (> 20M) join_buffer_size (> 1.0M, or always use indexes with joins) table_cache (> 600) innodb_buffer_pool_size (>= 25G)
2) Java Memory allocation to Tomcat
Java memory used: 1,580 Mb / 5,897 Mb
3) Physical Memory
If the server is running out of memory then the operating system will write memory to hard disk which substantially and abruptly slows the server. Look at Admin > System Reports > System status for the box called vmstat. Other methods at the command line include systat, free, htop, and top.
$ vmstat procs -----------memory---------- ---swap-- -----io---- -system-- ------cpu----- r b swpd free buff cache si so bi bo in cs us sy id wa st 0 0 215460 320852 607348 6405012 0 0 217 168 4 6 12 2 82 3 0
4) Oscar indices
select hl7textinf0_.id as id332_, hl7textinf0_.accessionNum as accessio2_332_, hl7textinf0_.discipline as discipline332_, hl7textinf0_.filler_order_num as filler4_332_, hl7textinf0_.final_result_count as final5_332_, hl7textinf0_.first_name as first6_332_, hl7textinf0_.health_no as health7_332_, hl7textinf0_.lab_no as lab8_332_, hl7textinf0_.label as label332_, hl7textinf0_.last_name as last10_332_, hl7textinf0_.obr_date as obr11_332_, hl7textinf0_.priorSimply.ity as priority332_, hl7textinf0_.report_status as report13_332_, hl7textinf0_.requesting_client as requesting14_332_, hl7textinf0_.result_status as result15_332_, hl7textinf0_.sending_facility as sending16_332_, hl7textinf0_.sex as sex332_ from hl7TextInfo hl7textinf0_ where hl7textinf0_.accessionNum like ?
long_query_time=2
log-slow-queries=/var/log/mysql/log-slow-queries.log
log-queries-not-using-indexes
Note that the slow-log itself can slow performance. Turn it off when you are not using it!
5) Tomcat Settings
Tomcat is usually installed with the same settings used in a development box or a small clinic. That's fine until you notice that you are running slow, and its necessary to change the defaults to more appropriate settigns.
By default, the maxThreads attribute is set to a meagre 200. This is appropriate for a single core machine, but those have not been made for years. Simply multiply by the number of cores and processors that your server has by 200. On a server grade machine with two Xenon processors with 6 cores each, setting this value to anything between 1000 and 2000 will not cause a problem. This is not wasteful as the thread pool will naturally scale back from this number when the server load is low.
Compression is another easy gain. Moving data on the network is slow, even more so on the internet. Setting compression on will allow for all the text and html that you are sending to OSCAR be transferred up-to 8 times faster.
Putting it together your server.xml might have an entry that looks like the following (taken from a production tomcat 7 example)
<!-- Define a SSL Coyote HTTP/1.1 Connector on port 8443 --> <Connector protocol="HTTP/1.1" port="8443" maxThreads="1000" scheme="https" secure="true" SSLEnabled="true" keystoreFile="/etc/tomcat7/.keystore" keystorePass="changeit" clientAuth="false" sslProtocol="TLS" maxPostSize="0" minSpareThreads="80" maxSpareThreads="160" compression="on" compressableMimeType="text/html,text/xml,text/plain" ciphers="TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256,TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256,TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384,TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384,TLS_DHE_RSA_WITH_AES_128_GCM_SHA256,TLS_DHE_DSS_WITH_AES_128_GCM_SHA256,TLS_ECDHE_RSA_WITH_AES_128_SHA256,TLS_ECDHE_ECDSA_WITH_AES_128_SHA256,TLS_ECDHE_RSA_WITH_AES_128_SHA,TLS_ECDHE_ECDSA_WITH_AES_128_SHA,TLS_ECDHE_RSA_WITH_AES_256_SHA384,TLS_ECDHE_ECDSA_WITH_AES_256_SHA384,TLS_ECDHE_RSA_WITH_AES_256_SHA,TLS_ECDHE_ECDSA_WITH_AES_256_SHA,TLS_DHE_RSA_WITH_AES_128_SHA256,TLS_DHE_RSA_WITH_AES_128_SHA,TLS_DHE_DSS_WITH_AES_128_SHA256,TLS_DHE_RSA_WITH_AES_256_SHA256,TLS_DHE_DSS_WITH_AES_256_SHA,TLS_DHE_RSA_WITH_AES_256_SHA" />
Detailed elsewhere is the Apache Portable Runtime (APR) based Native library for Tomcat. This connector is optimized for speed in part by using OpenSSL for encryption rather than Java Secure Socket Extension (JSSE). This is used for Tomcat production and uses slightly different SSL settings for the connector.
6) Upgrade hardware to a bigger faster box
This is so rarely the issue that I hesitate to suggest it. However if you are big enough (number of users say > 100) MySQL starts slowing down. The real symptom of this is that people start volunteering for evening shifts so that they can get through their inboxes quickly.
You should only consider a bigger box(s) after you have exhausted the above. In those cases there are ways to split off the OSCAR server(s) from multiple MySQL (or MariaDB) servers that load balance. This is hard core sys admin stuff where most OSCARs have not gone. Good luck and report back your challenges and success to the list!
Document Actions