28Apr/110

MySource Matrix performance analysis : Log dump all database SQL queries

Posted by Rianto Wahyudi

MySource Matrix

Wanted to know why your mysource matrix installation running slow ?One major issue with our installation is  matrix execute large  number of SQL queries. The individual query by itself is very lightweight and executed fairly quick, but there are hundreds to thousands of queries required just to bring up a page.

I've experienced up to 5,000 SQL queries (  2 Mega Bytes in size !) just to bring up  2 KB html page. In this case,  powerful , grunty and well tuned  database server  just won't help improving  page load time. ( Network latency between app server and database server is  0.6 ms at best, so theoretical minimum page load time is 3 seconds. On top of that, there are databases and applications processing overhead. If combination of the database and application overhead takes around 0.5 millisecond to process, the page load time will be around 5.5 seconds. 5.5 seconds to bring up 1 html page with no assets  is too long !)

 

 

 

 

 

If you curious  to see these how many queries your matrix produce, you can use log_dump tools to log these queries into system.log To do this ,edit the  following file :

core/lib/MatrixDAL/MatrixDAL.inc

Add following  line at the top of the line :

require_once ('/fudge/dev/dev.inc');

Add log_dump() function at the end of  preparePdoQuery function ( Around line 285 - just before "return $query" )


log_dump($query);
return $query;

Output will be written to'/data/private/logs/system.log

UPDATE :

Squiz Matrix 4.4.1 ships with awesome "Performance Mode".  It can be accessed just by appending /_performance at the end of  the URL of your matrix site.

From : http://www.squizlabs.com/squiz-matrix/squiz-matrix-performance-mode

Performance Mode will analyse the performance of the currently viewed asset present its findings at the base of your browser

These performance results will report the total time taken to load the asset and how much of this time can be attributed to system processing; the remaining time due to individual asset loading.

The individual assets that have been loaded will be listed chronologically, displaying their name, asset ID and asset type, as shown in the image below.

mysource matrix squiz performance
29Mar/110

Postfix for DEV setup – Catch all email and forward it to a specific address

Posted by Rianto Wahyudi

Postfix Logo

On one hand we had a situation where DEV or QAS server accidentally sending email to various recipient. On the other hand we have developers and QA tester wanted to test and make sure that email functionality works. On top of all of these, the admin guys still want to receive their email coming from the server ie cron and logwatch email.

The following setup will configure postfix to accommodate all the requirements above. Postfix will prevent all outgoing email (black hole) . Instead of just dropping the email we capture and send a blind carbon copy (bcc) to a specific email address, leaving the “TO Address” intact. It will also allow selected mail to be routed to the original owner as well as the specific account receiving it.

Here is the config :

master.cf :

Add following at the end of master.cf . This will create a “discard” service.

discard   unix  -       n       n       -       -       pipe
user=nobody argv=/bin/cat /dev/null

main.cf :

Add the folllowing lines. All 3 lines are important. The first line is to configure BCC address. The second line is configure the email routing. The last line specifies that all domains are virtual domain for this postfix mail server.

recipient_bcc_maps = pcre:/etc/postfix/recipient_bcc
transport_maps = pcre:/etc/postfix/transport
virtual_alias_domains =

recipient_bcc:

# BCC all email to :
/^(.*)/       catchallemail@example.com

transport:

/catchallemail@example.com/    smtp:mailgateway.example.com
/administrator@example.com/	 smpt:mailgateway.example.com
/.*localdomain$/    local:
/.*/    discard:

Ideas developed from :
http://www.somerandomstuff.com/2009/07/09/howto-mail-blackhole/
http://www.wiredfool.com/2002/06/11/how-to-blackhole-email-server/