Stivlo'st in Asia

Programming and Travel

Browsing Posts published in April, 2007

Excerpt from http://www.vim.org/tips/tip.php?tip_id=12

To insert space characters whenever the tab key is pressed, set the
‘expandtab’ option:

set expandtab

With this option set, if you want to enter a real tab character use
Ctrl-V<Tab> key sequence.

To control the number of space characters that will be inserted when
the tab key is pressed, set the ‘tabstop’ option. For example, to
insert 4 spaces for a tab, use:

set tabstop=4

After the ‘expandtab’ option is set, all the new tab characters entered
will be changed to spaces. This will not affect the existing tab
characters. To change all the existing tab characters to match the
current tab settings, use

:retab

I knew already, but I was caught again. I was wondering why my Java WebService was slow, I thought to profile the code, but when I checked the process list on the server I saw that MySQL was taking a lot of CPU time.

I looked into queries and I saw that in one of them I put ORDER BY RAND(), it was a join of two tables, one of which with around 300,000 records.

Aaahh! That was the problem. I tried the query alone with the RAND() 5,9 seconds of execution time, and without it 0,01 seconds. Since the RAND() wasn’t really needed I just removed it. In case it’s needed there are tricks to obtain a random row faster.

mod_jk with Tomcat 5.5

No comments

One year ago I was moving my first steps with Java webservices and today with Java annotations the task to write a webservice is easier.

I’ve already talked about installing mod_jk but it was with Java 1.4 and Tomcat 4.1. Today I’m trying with Java 1.6 and Tomcat 5.5 with apache 1.3.

From http://www.apache.org/dist/tomcat/tomcat-connectors/jk/source/ I get the source code of the current stable (1.2.21).

$ tar xfvz tomcat-connectors-1.2.21-src.tar.gz
$ cd tomcat-connectors-1.2.21-src/native
$ ./configure –with-apxs=/usr/local/bin/apxs
$ make
$ sudo make install

Libraries have been installed in:
/usr/local/libexec

$ vi /usr/local/conf/workers.properties

# Define 1 real worker using ajp13
worker.list=worker1
# Set properties for worker1 (ajp13)
worker.worker1.type=ajp13
worker.worker1.host=localhost
worker.worker1.port=8009

In /usr/local/conf/httpd.conf I add the following line

Include conf/mod_jk.conf

 

$ vi /usr/local/conf/mod_jk.conf

# Load mod_jk module
LoadModule jk_module libexec/mod_jk.so

# Declare the module for <IfModule directive> (remove this line on Apache 2.x)
# AddModule mod_jk.c

# Where to find workers.properties
# Update this path to match your conf directory location (put workers.properties next to httpd.conf)
JkWorkersFile /usr/local/conf/workers.properties

# Where to put jk shared memory
# Update this path to match your local state directory or logs directory
JkShmFile /usr/local/logs/mod_jk.shm

# Where to put jk logs
JkLogFile /usr/local/logs/mod_jk.log

# Set the jk log level [debug/error/info]
JkLogLevel info

# Select the timestamp log format
JkLogStampFormat “[%a %b %d %H:%M:%S %Y] “

# Send everything for context /examples to worker named worker1 (ajp13)
JkMount /kines_api/* worker1
JkMount /private_api/* worker1

After the tests, JKMount will be defined in apache VirtualHost context.

Powered by WordPress Web Design by SRS Solutions © 2010 Stivlo'st in Asia Design by SRS Solutions