1. Zipping the static content(images,css,javascript) and page response.
This can be achived by using the following configuration on the apache vhost configuration
For static content
<FilesMatch "\.(html|htm|js|css)$">
SetOutputFilter DEFLATE
</FilesMatch>
For page response ending with .do requests
<LocationMatch "\.(do)$">
SetOutputFilter DEFLATE
</LocationMatch>
2. Adding expires header
<FilesMatch "\.(jpg|jpeg|png|gif|swf)$">
Header set Expires "Wed, 31 Dec 2008 23:59:59 GMT"
</FilesMatch>
Expires also can be set as access plus x days
By adding this all images with the above extensions will not be requested.
If the above is missing all requests are made and images are downloaded for every requests.
if the browser cache is enabled , still Get requests are made and if the response is 304 meaning file has not changed the image will not be downloaded else
will download the image.
3. KeepAlive On
KeepAliveTimeout 15
MaxKeepAliveRequests 100
By setting this on httpd.conf the connection once obtained will not be disconnected until 15 seconds. Hence the multiple requests on a page will be faster.
The disadvantage could be , if the requests are very high the latter once will not get a connection until these are closed.
The cache setting will override the expires header setting, if it is less than the time interval for expires header.
Wednesday, August 6, 2008
Web Performance Techniques
Must use Addons With FireFox
FireBug - Shows request basis data along with headers and allows easy debugging of html content.
Web developer - Comes with lot of web development features like enable/disable cache/image/css/form data/proxy etc.
Live HTTP headers - Gives all trhe details required with headers.
Tamper Data -gives header data and also allows to tamper the data.
Tuesday, August 5, 2008
Replacing RMI with Spring Remoting
Custom classes used
com.px.site.db.IExampleService - Service Interface
com.px.site.db.ExampleService - - Service Implementation
EXAMPLE_SERVICE_URL - urel (Ex :htpp://10.x.x.x/context/ExampleDetails
context - is the context name under jetty/tomcat where the remote service is running
All other classes are from the spring jar
Service Code(Server)
The bean is instantiated in the service side using the following entry in the spring xml
<bean id="exampleProxy" class="com.px.site.db.ExampleService"/>
The implementation is provided to the main applicatuion calling the following url
<bean name="/ExampleDetails" class="org.springframework.remoting.httpinvoker.HttpInvokerServiceExporter">
<property name="service" ref="exampleProxy"/>
<property name="serviceInterface" value="com.px.site.db.IExampleService"/>
</bean>
The the application can get a reference using the url --> htpp://10.x.x.x/context/ExampleDetails
Main Application Code(client)
The service reference is obtained in the main application by adding the following in the spring xml where
EXAMPLE_SERVICE_URL is htpp://10.x.x.x/context/ExampleDetails obtained from any of the config parameters
<bean id="exampleService" class="org.springframework.remoting.httpinvoker.HttpInvokerProxyFactoryBean">
<property name="serviceUrl" value="${EXAMPLE_SERVICE_URL}"/>
<property name="serviceInterface" value="com.px.site.db.IExampleService"/>
</bean>
Now this service if needed can be used directly in any action or injected into any main service.
<bean id="application" class="com.examples.main.application">
<property name="exampleService" ref="exampleService"/>
</bean>
Them main advantage of this is a application can speak to any service which is remotely located.
Monday, August 4, 2008
Spring timer tasks for Threads
Create the bean which should be called on regular intervals.
This bean should extend the TimerTask and should have the run method which will be called on timely basis.
<bean id="example" class="com.examples.foo">
Make the bean a task and provide the time interval when it needs to be called. The time could be picked from property files.
<bean id="exampleTask" class="org.springframework.scheduling.timer.ScheduledTimerTask">
<property name="period" value="${exampleTime}">
<property name="timerTask" ref="example">
</property>
Add the tasks as part of Timerfactory which will be called based on the time given.
<bean id="timerFactory" class="org.springframework.scheduling.timer.TimerFactoryBean">
<property name="scheduledTimerTasks">
<list>
<ref bean="exampleTask">
</ref>
</list>
</property>
All the above entries will be part of the spring xml.More then one tasks can be added to the timerfactory
</bean></property></bean></bean>
Prototip for easy and Fancy tool Tips
Just came across Prototip which helps to create javascript based tool tips with ease
http://www.nickstakenburg.com/projects/prototip2/.
Could not work more on it as we needed something which supports from IE 5+ versions. Protip supports IE 6+ and Firefox 2+
Running Parallel Db queries on huge Databases.
When the size of the table is very high and the column you are looking for is not indexed then the best way to run the query would be by parallel execution.
This really speeds up the process . But the catch here is that the CPU utilization is high and in production systems this may end up in locks.
This technique can be safely used in backup db servers.
Example
SELECT /*+ parallel(huge_table,4 ) */ * FROM huge_table;
where 4 is the degree of parallelism.The degree of parallelism depends on the capacity of the machines.
Friday, August 1, 2008
Loading multiple property files using Spring
While loading multiple files using spring the following property needs to be added
into
.jpg)