Articles clasified as "Tech stuff"
Go back to the homepage

Map Application Performance Tuning - Part 3

01/19/2010

The performance of the Tilecache server can be improved by using mod_python instead of CGI. This blog post shows the results of a benchmark test made on a windows machine.

1. Installing mod_python on OpenSuse is easy with Zypper:
# sudo zypper install apache2-mod_python
did the job.

2. I added a configuration file to /etc/apache2/conf.d named mod_python.conf with the following entries:

LoadModule python_module /usr/lib64/apache2/mod_python.so
<Directory /webservice/cgi-bin/tilecache/><br/> AddHandler python-program .py<br/> PythonHandler TileCache.Service<br/> PythonOption TileCacheConfig /webservice/cgi-bin/tilecache/tilecache.cfg<br/> </Directory>
3. I restarted Apache2. The error_log in /var/log/apache2/ indicates that the module was also loaded successfully:
Apache/2.2.10 (Linux/SUSE) mod_ssl/2.2.10 OpenSSL/0.9.8h mod_fastcgi/2.4.6 mod_python/3.3.1 Python/2.6 Phusion_Passenger/2.2.5 configured -- resuming normal operations

4. I changed the code of my application and replaced tilecache.cgi by tilecache.py:
var layer = new OpenLayers.Layer.WMS("name","http://localhost/cgi-bin/tilecache/tilecache.py", { maxExtent:new OpenLayers.Bounds(-198,-115.542749339137,198,109.146905833277), maxResolution:156543.0339, layers:"worldtest", transparent:true });

5. Did the first test and it really seems to be noticeably faster. YEAH!

Map Application Performance Tuning - Part 2

01/19/2010

An advice for optimizing the performance of Mapserver was to use FastCGI.

1. I installed the FastCGI library with yast and downloaded the Apache2 module mod_fastcgi-2.4.6.tar.gz. After extracting it, I followed the configure, make, make install dance as described. Unfortunately the compiler complained about some missing stuff and I couldn´t figure out how to get the module installed. I gave it up and tried the mod_fcgid module from Apache itself that seemed to be quite similar.

3. I extracted mod_fcgid-2.3.4.tar.gz to my home directory and followed the steps described in the README:
# APXS=/usr/sbin/apxs2 ./configure.apxs
# and following 'make'
The compiler returned the same problem and complained about a missing mpm.h and mpm_default.h in /usr/include/apache2.

I came around the problem by symlinking both files using
# ln -s ../apache2-prefork/mpm.h mpm.h
# ln -s ../apache2-prefork/mpm_default.h mpm_default.h

After doing that both modules were build successfully into /usr/lib64/apache2.

4. I added a configuration file to load the module in /etc/apache2/conf.d with the following entry:
LoadModule fastcgi_module /usr/lib64/apache2/mod_fastcgi.so

5. I restarted Apache with apache2ctl restart. The error_log in /var/log/apache2/ indicates that the module was loaded successfully:
Apache/2.2.10 (Linux/SUSE) mod_ssl/2.2.10 OpenSSL/0.9.8h mod_fastcgi/2.4.6 Phusion_Passenger/2.2.5 configured -- resuming normal operations

Map Application Performance Tuning - Part 1

01/19/2010

My current task is to improve the performance of a web application that runs on Apache 2.2.10 on OpenSuse 10.6, 64bit. It is a map application that works with Google Maps JavaScript API, OpenLayers JavaScript API on the client side and a Mapserver on the server side.

After discovering that the response time of my server was sometimes quite long (using firebug), I decided to start optimizing the server side application first.

1. First step I did was installing Tilecache, a Python-based server that caches tiles from different sources on disk. Installation is easy and straightforward. The test run worked correctly.

2. Figuring out how my application or better a OpenLayers.Layer.WMS object could request tiles via Tilecache that were formerly requested from Mapserver was a little bit harder. First I had to install Python MapScript (to enable communication between Tilecache and Mapserver). which I managed by following the advices "Building and Installing Python MapScript" in Chapter 7 from the "Beginning MapServer" book from Bill Kropla. As far as I know now, each map that should be cached by and requested via Tilecache has to have a correct entry in tilecache.cfg that resides /webservice/cgi-bin/tilecache/.

Example:
[worldtest]
layers = country
spherical_mercator = yes
extension = png
mapfile = /webservice/rails/cigrasp/shared/assets/maps/tobi/world_test/world_test.map
data_extent = -198.0,-115.542749339,198.0,109.146905833
type = MapServer
metatile = no
srs = EPSG:4326
metabuffer = 10,10
bbox = -198.0,-115.542749339,198.0,109.146905833
metasize = 5,5
extent_type=loose


This layer can requested via an OpenLayers.Layer.WMS object as follows:
var layer = new OpenLayers.Layer.WMS("name","http://localhost/cgi-bin/tilecache/tilecache.cgi", { maxExtent:new OpenLayers.Bounds(-198,-115.542749339137,198,109.146905833277), maxResolution:156543.0339, layers:"worldtest", transparent:true });

Introduction to SCRUM

01/04/2010

While searching for a methodology to get some kind of structure into my software development process, I remembered SCRUM. This video is an excellent introduction to this agile project methodology. Still have to figure out how to make this work in our special team and development situation.

Installing MySQL and mysql gem on Snow Leopard

12/17/2009

It´s really a hard job figuring out how to get MySQL and mysql gem up and running on Snow Leopard 10.6.2. I followed the instructions of various posts but was not successful yet:

First I followed this instruction http://hivelogic.com/articles/compiling-mysql-on-snow-leopard/" and build MySQL Version 5.1.39 from source. It installed successfully. When trying to login using (mysql -u root -p) mysql returned the following error: ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2), that obviously meant that the MySQL Server (mysqld) was not running (ps -axf | grep mysqld).

which mysql: /usr/local/mysql/bin/mysql
which ruby: ruby 1.8.7 (2009-04-08 patchlevel 160) [i686-darwin9])
gem -v: 1.3.5
mysql: Server version: 5.1.39 MySQL Community Server (GPL)

After a lot of googling around, I found out that

1. this command can start mysqld:
sudo /usr/local/mysql/bin/mysqld_safe --user=mysql &

2. The Preference Pane MySQL Tool is probably broken in Mac OS X 10.5 and higher

3. This command should install the mysql gem correctly on Snow Leopard:
sudo gem uninstall mysql
sudo env ARCHFLAGS="-arch x86_64" gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config
(See this post: http://stackoverflow.com/questions/1366746/gem-install-mysql-failure-in-snow-leopard

It ended up that I got the following error using something like rake db:create:
dyld: lazy symbol binding failed: Symbol not found: _mysql_init Referenced from: /opt/local/lib/ruby/gems/1.8/gems/mysql-2.8.1/lib/mysql_api.bundle Expected in: flat namespace dyld: Symbol not found: _mysql_init Referenced from: /opt/local/lib/ruby/gems/1.8/gems/mysql-2.8.1/lib/mysql_api.bundle Expected in: flat namespace

This error led me to the following post: http://cho.hapgoods.com/wordpress/?p=158, that basically tells me that the Ruby Version that came together with XCode 3.0 does not work in 64bit environments and a solution could be to install the 32bit version. Arrrgghh!

The first answer to my post @ stackoverflowled me to the right track, doing the stuff with macports.

The way I finally solved this issue was uninstalling / reinstalling XCode and all my ports as described here:
http://trac.macports.org/wiki/Migration

MacBook Pro Trackpad Fix

09/06/2009

Das Trackpad beim neuen MacBook kann z.B. bei der Arbeit im Browser sehr nervig sein, wenn man mit beiden statt mit einem Finger Scrollen will und sich dadurch ständig die Seite verkleinert bzw. vergrößert. Nach langem Suchen bin ich heute endlich auf einen einfachen Fix gestoßen: http://cubeyellow.blogspot.com/2009/01/mac-book-pro-trackpad-zooming-and.html