Showing posts with label Optimizing. Show all posts
Showing posts with label Optimizing. Show all posts

Tuesday, June 25, 2013

Using Memcached with Symfony 2 (on CentOS 6)

The biggest problem, that I've been running into for years, is always performance. But sometimes optimizing your code isn't good enough, sometimes because you're depending on external libraries, which you don't want to change.

For one of our customers, I ran into this problem as well, so I had to find a solution. I've already heared about Memcached often, but I never had the time to look into it and I was kinda scared to have to implement it in an already existing application. Afterwards, I found using the basics of memcached was pretty simple, and it boosted my page speed by 50-75%(!), only by caching doctrine queries and results.

A quick Google search found me a bundle that claims to do exactly what I want: the LswMemcacheBundle. LswMemcacheBundle is developed by LeaseWeb, which leverages the power of the PHP 'memcached' extension (not the older 'memcache' PHP extension, the d make a huge difference as explained on http://code.google.com/p/memcached/wiki/PHPClientComparison).

The installation instructions looked quite simple: install memcached, install the memcached extension and add one line to your composer.json. For Debian based systems this is the case, but CentOS 6 has some obstacles in place.

With CentOS 6 there are a couple problems:
  1. The php extension 'memcached' requires libmemcached. Unfortunatly the version of libmemcached in yum is to old to meet the requirements
  2. The php memcached extension can't be installed trough yum, so this has to be installed trough pecl
  3. Installing the php memcached extension trough pecl threw some errors while compiling.

Friday, December 7, 2012

Bundle for faster generation of entity dropdowns for Symfony 2

Soon after writing my previous blog, where I described a way to speed up the rendering of entity dropdowns, I received lots of feedback about better and nicer ways of doing this. All the suggestions where the same: use a custom form type and a datatransformer.

So I did for one entity, but I didn't feel like doing it for every entity. So I wrote a console command that allowed me to do this automatically (for one or all entities within a bundle).

After a short discussion with my boss, we agreed upon releasing the generator to the public and today the day is here.

The bundle is located at https://github.com/TheDevilOnLine/Symfony-FastEntityBundle and can be installed via composer. For all the details please take a look at https://github.com/TheDevilOnLine/Symfony-FastEntityBundle/blob/master/README.md

Oh and feel free to say thanks to my boss (Martijn) in the comments, for allowing me to opensource otherwise proprietary code.

P.S. This is my first time releasing code using composer, so please report any bugs you might run in to on GitHub: https://github.com/TheDevilOnLine/Symfony-FastEntityBundle/issues

Thursday, November 22, 2012

Speeding up the rendering of entity dropdowns in forms in Symfony 2

Update: See http://12wiki.blogspot.nl/2012/12/bundle-for-faster-generation-of-entity.html for an improved implementation.

One of the great features of Symfony 2 is the simplicity of rendering a form, even when you're using external entities. The only problem is that rendering a dropdown with 3662 entities is quite slow. In my case this took almost 2 seconds!

Wednesday, November 21, 2012

How to time your own events in Symfony 2?

As some of you might have noticed by now, I am quite interested in the performance of my application. Since Symfony 2 has such a great profiler I was looking for a way to time my own code within the existing profiler and without writing to much code.

Monday, November 12, 2012

Why does the Symfony 2 firewall take so long to load?

During the development of my current project, I noticed in the profiler that the Firewall took about 1 second to load, which was more than 50% of the total load time.