29
May/08
0

Google Earth / Map Implementation Problem

One thing that was not documented fully at Google for integrating Google Earth into Google Map is that the function, getEarthInstance, is only available in the newest version of the Map API. I could not find exactly which version so the best way is to use v=2.x like in “http://maps.google.com/maps?file=api&v=2.x&key=yourkey” instead of specifying an exact version. Have fun with this new feature.

29
May/08
0

Google Earth on Google Maps

Google just added a new Earth plugin feature to Google Maps.  Now we can have all the functionalities of Earth as one of the selections buttons on Maps just like Satellite view.  This is a very exciting new development.

19
May/08
0

php strip_tags problem

I found that using php function, strip_tags, does not remove all the markup elements correctly from the subject content.  First of all, if an anchor link includes a line break, it will not be removed correctly.  Also, the style information is not properly removed as well.  In the following script, I also added in the regex to remove any content in between script tags, but that may or may not be necessary.

function strip_all_tags($content)
{
$content = preg_replace(’/\n/’,’ ‘,$content);
$content = preg_replace(’/<script.*<\/script>/U’,’ ‘,$content);
$content = preg_replace(’/<style.*<\/style>/U’,’ ‘,$content);
$content = strip_tags(strtolower($content));
return $content;
}

The function will remove all line breaks so strip_tags will not have problems with finding all markups.  Since strip_tags does not remove <style> tags, the new function will remove them using regex.

9
May/08
0

Mysql on 32bit processor vs 64bit processor

Here is the continuation of the experiment done previously on Mysql on Windows vs Linux. After doing more analysis and observation, it appeared that the difference in speed for the benchmark tests were not related to Windows and Linux but were related to the processor. The previous test just happened to have AMD 64s on the Linux machines and Intel Xeon 32bits on Windows. We hypothesized that the increased throughput of the 64bit processors resulted in about half the time required to return the same query run on a 32bit machine.

View the previous results

So we decided to test the same query again on a Windows machine with an AMD 64 X2. This time the result for the query took 7.35 second, almost the same as the other AMD 64s running Linux.

One more test to run the query on a Windows Intel 64bit chip machine would better solidify our hypothesis.

2
May/08
0

Mysql server has gone away

I have a spider crawling the web written in PHP running constantly to insert and update data in a Mysql database.  Today, it kept stopping on a records with the error message, “Mysql server has gone away”.  It certainly did not time out as just starting the process again would result in this message immediately.  The script did not close out the connection to the DB as it had worked just fine for over a year.

Finally, I found that the problem was max_allowed_packet setting in my.cnf was too small.  It was set to 2MB and when Mysql receives a query larger than that, it assumes that something must have gone wrong and closes the connection.  I increased that parameter to 4MB and everything is working fine now.

1
May/08
2

Mysql on Windows vs Linux

I was working on optimizing a Mysql database today and accidentally stumbled upon a benchmarking exercise. The original Mysql database is hosted on a Windows Server 2003. I develop on a Mysql database server running on Ubuntu Linux. The Linux server ran the same query twice as fast as the Windows server without using caching or anything. I know that Linux does I/O caching on its own as well so I even tried running the query after a fresh reboot to rule out that factor. Then I got help from a colleague and started tweaking with the my.cnf/my.ini to make sure they were the same and each time, the results came back about the same. Mysql on Windows was consistently slower than Mysql on Linux.

Then we decided to load the database onto other servers for more data points on this Mysql performance test. We ran the same query returning 429 rows of data with 13 table joins and a couple of sub-queries. All queries were run on the command line client on the servers themselves to avoid network lag.  All servers are running Mysql 5.0.x.

Results

1. Ubuntu Linux: 0.70 seconds
2. CentOS: 0.78 seconds
3. Windows 2003 Server: 1.40 seconds
4. Windows 2003 Server: 1.42 seconds

Server hardware

1. Ubuntu Linux
AMD ATHLON 64 X2 4200+
2GB DDR400
200GB 7200RPM SATA/150

2. CentOS
Dual Opteron 240
2GB DDR ECC
120GB 7200RPM SATA/300

3. Windows 2003 Server
Dual Xeon
2GB DDR ECC
7200RPM PATA

4. Windows 2003 Server
2 Dual Xeon (4 CPUs)
8GB DDR ECC
3 73GB 10,000RPM SCSI in RAID 5

A followup to the benchmark that clarifies the cause of the differences