Posts Tagged ‘performance’
Monday, January 25th, 2010
If you have ever looked at the console or logs while starting a Tomcat instance on Windows you have probably seen the following line about APR.
INFO: The Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path
As long as the “tcnative-1.dll” is in the Windows PATH, generally you can place it in c:\windows\system32, but any other location in the PATH will work should you need it to be portable, or have different versions in use.
NOTE: Other Operating Systems use a similar approach as Windows to add an environmental variable, optionally you can also add the appropriate location to the “java.library.path” attribute used when calling the VM, if you are more technically inclined.
Cheers
Tags: apache, apr, dll, java, jni, native. library, performance, tomcat, win32, windows
Posted in Work | No Comments »
Tuesday, December 22nd, 2009
For a very long time I was perplexed as to why my old 900Mhz Pentium-3 server outperformed many of my newer and faster machines, even when they all were running with essentially the same amount of memory and had the same 7200rpm hard-drives.
I recently realized that over the years, I had optimized the WindowsXP NTFS registry settings with a variety of software and manual edits, and thus had essentially changed the way that windows works with the drive itself.
Here are the current settings that these machines utilize, perhaps you can try them for yourselves:
WARNING: You need to be confortable making edits to your registry to do these changes, as such I will not document ‘how’ to open the registry itself, you can easily find that info anyways. These are all DWORD settings.
HKLM\SYSTEM\CurrentControlSet\Control\FileSystem
- DisableNTFSLastAccessUpdate = 1
- NtfsDisable8dot3NameCreation = 1
- NtfsDisableLastAccessUpdate = 1
- NtfsMftZoneReservation = 2
Cheers
Tags: disk, ntfs, performance, registry, windows
Posted in Work | No Comments »
Sunday, November 29th, 2009
Eventually, you come to a point where the performance of JavaScript becomes an issue. Most modern browsers have made significant improvements in their javascript engines, unfortunately Microsoft has yet to do the same. MSIE’s (at least up to and including MSIE8) javascript performance lags far behind Mozilla/Firefox, Safari, Chrome and Opera.
String concatenation is extremely slow in MSIE, but arrays are generally fast… as such it’s often beneficial to implement an object similar to the Java StringBuffer (or StringBuilder) for JavaScript.
The StringBuffer implementation… you can customize to make it more functional, but this is the core:
function StringBuffer(){
this.buffer = [];
}
StringBuffer.prototype.append = function append(string){
this.buffer.push(string);
return this;
};
StringBuffer.prototype.toString = function toString(){
return this.buffer.join(”");
};
Example:
function example_slow(x1,x2,x3){
var rc = x1;
rc+=x2;
rc+=x3;
return rc;
}
function example_fast(x1,x2,x3){
var sb = new StringBuffer();
sb.append(x1);
sb.append(x2);
sb.append(x3);
return sb.toString();
}
References:
Cheers
Tags: javascript, msie, performance, string, stringbuffer, stringbuilder
Posted in MSIE bugs, WebStandards, Work | No Comments »
Thursday, October 29th, 2009
Here’s a useful trick for minimizing server HTTP connections, unfortunately it’s not universally supported so you will need to provide alternate methods for non-supporting browsers (such as MSIE).
This works by placing the content of the image into the URL itself, as such there’s no need to open up a new server connection and no extra caching at any tier.
<img src=”data:image/gif;base64,R0lGODlhEAAOALMAAOazToeHh0tLS/7LZv/0jvb29t/f3//Ub/ /ge8WSLf/rhf/3kdbW1mxsbP//mf///yH5BAAAAAAALAAAAAAQAA4AAARe8L1Ekyky67QZ1hLnjM5UUde0ECwLJoExKcppV0aCcGCmTIHEIUEqjgaORCMxIC6e0CcguWw6aFjsVMkkIr7g77ZKPJjPZqIyd7sJAgVGoEGv2xsBxqNgYPj/gAwXEQA7″ alt=”embedded folder icon” width=”16″ height=”14″ />
Tags: base64, data, html, http, image, img, network, optimization, performance, url
Posted in WebStandards, Work | No Comments »
Wednesday, February 11th, 2009
I spend a LOT of time trying to optimize web applications to run and appear as fast as possible, one of the most valuable tools I have in my “bag of tricks” is the YSlow! plugin for Firefox.
It integrates in the browser and gives a near real-time scoring of the pages you visit and suggestions on how to improve them. While some of the suggestions are not practical (for example: use of a CDN) the bulk of them can be applied to your application code or server with a little bit of work.
The rules and scoring mechanisms are well documented at the following website:
http://developer.yahoo.com/performance/
The YSlow! plugin is available here:
http://developer.yahoo.com/yslow/
Happy… Faster Surfing!
Tags: browser, cache, firefox, html, http, javascript, network, performance, plugin, speed, standards, yslow
Posted in WebStandards, Work | No Comments »
Tuesday, April 22nd, 2008
Often you want to use Apache HTTP for static content, yet use Tomcat for JSP and other Java type work. This is a very common infrastructure for enterprise applications, particularly when using ‘pools’ of servers for performance, redundancy and security.
In order to accomplish this, all connections need to be handled by the Apache webserver, which will delegate appropriate requests to Tomcat for it to process.
Here’s a simple setup to get you started:
- First you need to get the connector appropriate to your installation:
http://tomcat.apache.org/connectors-doc/
- Next make sure the connector file is in the /conf folder of your Apache installation.
NOTE: I prefer to use this path and leave the version name to make maintenance and backups easier.
- Add the following line to httpd.conf
LoadModule jk_module conf/mod_jk-1.2.26-httpd-2.2.4.so
- Now, add the following to http.conf
<IfModule jk_module>
Include “c:/TOMCATPATH/conf/auto/mod_jk.conf”
JkWorkersFile conf/workers.properties
JkLogFile “c:/LOGSPATH/tomcat55_mod_jk.log”
</IfModule>
- Add the c:/APACHEPATH/conf/workers.properties file with the following (minimal) contents:
worker.list=ajp13
worker.ajp13.port=8009
worker.ajp13.host=localhost
worker.ajp13.type=ajp13
- Finally, restart both Apache and Tomcat
- The following file should have been created in c:/TOMCATPATH/conf/auto/mod_jk.conf
########## Auto generated on …some datetime… ##########
<IfModule !mod_jk.c>
LoadModule jk_module “C:/APACHEPATH/conf/mod_jk-1.2.26-httpd-2.2.4.so”
</IfModule>
JkWorkersFile “C:/TOMCATPATH/conf/jk/workers.properties”
JkLogFile “c:/LOGSPATH/mod_jk.log”
JkLogLevel emerg
<VirtualHost localhost>
ServerName localhost
JkMount /webdav ajp13
JkMount /webdav/* ajp13
JkMount /servlets-examples ajp13
JkMount /servlets-examples/* ajp13
JkMount /jsp-examples ajp13
JkMount /jsp-examples/* ajp13
JkMount /balancer ajp13
JkMount /balancer/* ajp13
JkMount /host-manager ajp13
JkMount /host-manager/* ajp13
JkMount /tomcat-docs ajp13
JkMount /tomcat-docs/* ajp13
JkMount /manager ajp13
JkMount /manager/* ajp13
</VirtualHost>
If all went well, you should be able to access your Tomcat server webapps on the regular HTTP port used by your Apache installation.
Cheers!
Tags: apache, configuration, connector, java, jsp, mod_jk, performance, server, servlet, tomcat
Posted in Work | No Comments »
Tuesday, April 22nd, 2008
Here’s another simple way to optimize code and network traffic. XML… by it’s very definition is wasteful as it exchanges size for readability. JSON is a different approach that maintains readability as well as reduces the size to a minimum. This method can be used in any client-server environment, not just between a browser and server.
JSON (JavaScript Object Notation) is a lightweight data-interchange format that is easy for humans to and machines to read/parse and write/generate. JSON is a text format that is completely language independent but uses conventions that are familiar to most programmers familiar with OO languages.
JSON is built on two structures:
- A collection of name/value pairs. In various languages, this is realized as an object, record, struct, dictionary, hash table, keyed list, or associative array.
- An ordered list of values. In most languages, this is realized as an array, vector, list, or sequence.
Key Concepts:
- An object is an unordered set of name/value pairs. An object begins with { (left brace) and ends with } (right brace). Each name is followed by : (colon) and the name/value pairs are separated by , (comma).
- An array is an ordered collection of values. An array begins with [ (left bracket) and ends with ] (right bracket). Values are separated by , (comma).
- A value can be a string in double quotes, or a number, or true or false or null, or an object or an array. These structures can be nested.
- A string is a collection of zero or more Unicode characters, wrapped in double quotes, using backslash escapes. A character is represented as a single character string. A string is very much like a C or Java string.
- A number is very much like a C or Java number, except that the octal and hexadecimal formats are not used.
REFERENCES:
Cheers!
Tags: javascript, json, messaging, network, object, performance, xml
Posted in WebStandards, Work | No Comments »
Monday, April 21st, 2008
I spend a lot of my time tweaking the performance of web applications, in addition to optimizing code it’s also necessary to verify that your server settings are also optimized for network performance to reduce bandwidth usage and thus client response times.
NOTE: This is a tradeoff between CPU and network performance, it works by compressing the content on the server just before it is sent over the wire…. when the client receives it, it then also spends some of it’s resources to decompress the content.
The Apache HTTP server provided mod_deflate (for 2.x) or mod_gzip (for 1.3).
Here’s a quick start as well as a few references:
In httpd.conf:
1. Uncomment the module:
LoadModule deflate_module modules/mod_deflate.so
2. Add the following (modify if required):
<IfModule deflate_module>
#AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css text/javascript
AddOutputFilterByType DEFLATE text/*
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
#AddOutputFilterByType DEFLATE application/x-javascript
<Location />
# Insert filter
SetOutputFilter DEFLATE
# Netscape 4.x has some problems…
BrowserMatch ^Mozilla/4 gzip-only-text/html
# Netscape 4.06-4.08 have some more problems
BrowserMatch ^Mozilla/4\.0[678] no-gzip
# MSIE masquerades as Netscape, but it is fine
# BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
# NOTE: Due to a bug in mod_setenvif up to Apache 2.0.48
# the above regex won’t work. You can use the following
# workaround to get the desired effect:
BrowserMatch \bMSI[E] !no-gzip !gzip-only-text/html
# Don’t compress images or ZIP/GZ/7Z
SetEnvIfNoCase Request_URI \
\.(?:gif|jpe?g|png|zip|7z|gz)$ no-gzip dont-vary
# Make sure proxies don’t deliver the wrong content
Header append Vary User-Agent env=!dont-vary
</Location>
</IfModule>
REFERENCES:
Cheers!
Tags: apache, browser, compression, deflate, gz, gzip, http, mod_deflate, network, performance, server
Posted in WebStandards, Work | No Comments »
Friday, April 11th, 2008
I’ve previously written on the benefits of static analysis of java code with the use of PMD and FindBugs. I was recently turned on to a new tool that performs similar testing of code within the Eclipse IDE.
When I first found this tool it was free, since that time it’s come out of beta and is now a little costly, but it may still be worth it due to the functionality it provides.
The premise of this tool is a little different than other ones, while it covers much of the same need, it also performs many tests that I would previously use CheckStyle to do. This only provides them at runtime and in a common manner within the IDE.
REFERENCES:
Cheers!
Tags: analysis, code, eclipse, ide, java, javadoc, performance, plugin, standards, static
Posted in WebStandards, Work | No Comments »
Monday, November 13th, 2006
I’ve used EveryDNS (free service) for years to host my DNS services. Recently I found that they now offer public DNS service for lookups as OpenDNS. While I still run my own private DNS server for caching and various private addresses. I now do a simple forward lookup to their servers to gain the extra services they provide… notably Phishing and typo protection.
Setup is very simple for most users, and even a non-technical person should have no problems following their installation instructions for a single computer/device or an entire network.
Happy networking!!!
Tags: dns, free, open, performance, security, server
Posted in WebStandards, Work | No Comments »