١٤٢٦/٠٢/٢٠

Add Alriyadh newspaper headlines to your website

Alriyadh newspaper UNOFFICALY releasing new service that allow you to add alriyadh.com headlines into yuor website, it very simple to include, for example if you are interstead in putting "Internet & Communication" into your website put this code into your website:

<iframe style="width:400px; height:30px; border:0px;" src="http://www.alriyadh.com/section.net_marque.html">

It will show into your website like this:


Of course you can change the section by replacing the file name:

  • Local News:
    http://www.alriyadh.com/section.local_marque.html
  • International News:
    http://www.alriyadh.com/section.inter_marque.html
  • Columns:
    http://www.alriyadh.com/section.columns_marque.html
  • Clinic:
    http://www.alriyadh.com/section.clinic_marque.html
  • Art & Culture:
    http://www.alriyadh.com/section.art_marque.html
  • Light News:
    http://www.alriyadh.com/section.misc_marque.html
  • Economy:
    http://www.alriyadh.com/section.econ_marque.html
  • Sport:
    http://www.alriyadh.com/section.net_marque.html

١٤٢٦/٠٢/١٠

Playing with Flickr API

Flickr has really amazing web service API, they support many transports REST, SOAP, and XML-RPC. I had some idea about SOAP, and XML-RPC, and never worked with REST, it turned out as the best and the simplest one of them.

All you need is API KEY which is a key you use every time you call a function, it is used by Flickr for statistics, you can get it from here Get a key, it is only one form, and you will get the key instantly.

This is a sample REST request:
/services/rest/?method=flickr.people.findByUsername&api_key=e8fda...

Give it a try it is really simple API, and simple interface.

١٤٢٦/٠٢/٠٣

PHP Accelerator is awesome

I have a server with PHPAdsNew installed serving around 20 requests per second serving a really busy web site.

Few days ago the admins for that website doubled the number of ads per page, and the server stopped responding most of the day :(

I installed PHP Accelerator to make it faster to serve the those ads, but it didn't help that much, I tried every trick I know to maximize MySQL performance (although it didn't have any load in the first place) nothing worked.

Today, I sat down and played a little with PHP Accelerator, I moved the cache directory from /tmp (mounted on swap) to a regular directory, and the amazing thing happened, the CPU utilization drop from 100% to 50%.

Then I tried the command "phpa_cache_admin -mv" to realize that PHP Accelerator is working without shared memory enabled, I enabled it and restarted Apache, the utilization drop to only 10% :)

I did all of these changes after the peak hour, I wonder how it will perform tomorrow in the peak hour, I'll post my results tomorrow.

UPDATE: Peak hour update, very smooth as if there aren't any requests, CPU utilization 40% :)

١٤٢٦/٠١/٢٨

Search engine speed improvements

I just replaced queries like these:
INSERT DELAYED INTO table (name1,name2) VALUES(value1,value2)
INSERT DELAYED INTO table (name1,name2) VALUES(value3,value4)
INSERT DELAYED INTO table (name1,name2) VALUES(value5,value6)
INSERT DELAYED INTO table (name1,name2) VALUES(value7,value8)


with one query:
INSERT DELAYED INTO table (name1,name2) VALUES (value1,value2), (value3,value4), (value5,value6), (value7,value8)

The indexer performance jumped from indexing 13 documents per second to 50, almost 4 times faster.

Another way to improve performance is to drop extra indexes during table updates, then create the index after wise, the performance improvements won't be visible until your table becomes very large, and the updating the index becomes very expensive.

Now indexing 45000 documents took around 15 Minutes, yesterday it took more than 4 hours and didn't even finish :)

١٤٢٦/٠١/٢٧

Building a search engine

Currently I am working on a search engine for a large website, the search engine is based on PHP+MySQL.

You may wonder why not use LIKE in SQL for searching! Of course LIKE will work with few documents, but how about tens of thousand of documents it would be very slow, since the DBMS would have top scan all reconrds one by one in your database to find the word you are looking for.

I decided to work on my own search engine after testing few applications, mainly mnogosearch, and PHPDig, both program didn't fit my need exactly, plus the support for Arabic wasn't that good either.

The engine should index 45000 document, currently the indexer can index 70 documents per second, which mean it would take 10 hours to index the whole thing.

The search engine needs a lot of tuning, like removing common words, removing Arabic Harkat, and Hamzat, hopefully I will end up with a nice reusable search engine.
I'll post a link when we put in production.