February 20th, 2009 | published by Alvaro
During the last two sprints we run in the need to perform statistic analysis to profile a symfony application. As I explained here symfony logs to the file system quite a lot of useful information regarding the request that is processing. We wanted to be able to easily parse those logs and then perform queries to filter data. The data was going to be collected form our productions servers, which means that whatever tool we choose must not impact the performance of the website. We knew that symfony logs to the filesystem which was not an option for our production servers.
Our first attempt was to research Facebook Hive and Facebook Scribe, but we declined the idea. We then thought that we could try to build our own tool, probably writing some daemon in Erlang, but something appeared in our way…
During the research regarding map reduce Wikipedia led me to the mighty CouchDB, which in their words is:
Apache CouchDB is a distributed, fault-tolerant and schema-free document-oriented database accessible via a RESTful HTTP/JSON API. Among other features, it provides robust, incremental replication with bi-directional conflict detection and resolution, and is queryable and indexable using a table-oriented view engine with JavaScript acting as the default view definition language.
I must say this: after seeing some examples about it’s functionality my mind blew off. It was awesome, awesome like in CouchDB :-)
Then the idea popped in my mind:
Why not to build a symfony logger that talks to CouchDB and create some CouchDB views that will produce the statistics? I was at home and It was late at night, but my inner geek told me: let’s give it a try.
Read the rest of this entry »
February 10th, 2009 | published by Alvaro
Below I will like to share some snippets for optimizing Propel queries.
Replace MyTablePeer::retrieveByPk() with a custom query.
If in our code we have something like:
if(MyTablePeer::retrieveByPk($id))
{
//do something here
}
Where we can see that the result from the retrieveByPk() call is used as a boolean, it is better to replace it with a custom query like this:
public static function recordExists($id)
{
$c = new Criteria();
$c->add(self::ID, $id);
return self::doCount($c) > 0;
}
This method will be added to the MyTablePeer class. Asuming that self::ID is the primary key of the table this will return true if there is a record entry with that id on the table -you should adapt the Criteria to your needs.
Read the rest of this entry »
February 6th, 2009 | published by Alvaro
How you dare to say that? I hear you saying.. Wait wait wait… Put down those torches… I may have a point here.
At the office I spent the last two days hunting a javascript bug on IE6, imagine how painful that can be, with no Firebug to come to rescue.
It happens that we are using the symfony sfCombine plugin to improve the performance of the website. Everything was going OK until someone dare to test the website with IE6. Imagine the picture: layout broken, javascript errors popping all around, mayhem, etc.
The bug was in a image gallery made with a Prototype based carousel library. After going to the line with the javascript error I saw that some extensions that the library performs on Prototype using Element.addMethods() didn’t worked at all.
Then the hunt started, as almost every time, in the wrong direction. -Maybe a lost semicolon that breaks the combinations. -No no, I think that the nginx is not sending the correct mime types. Etc. You can imagine all the thoughts going here and there.
I spent hours in front of IE6, hitting refresh, cleaning the browser cache, adding breakpoints in the Microsoft (R) Script(R) Editor(R), inspecting the objects in memory, evaluating Javascript code, etc.
No results. Nothing. Just null is null or not an object.
Read the rest of this entry »