Speed comparison of Postgresql modules for nginx Openresty

For an application we are working on that will track user interactions with things, we need the fastest possible solution in order not to slow down the other end (too much).

So I benchmarked the different PostgreSQL modules available for Openresty. Openresty is Nginx with LuaJit and other powerful features. It is very interesting because it is very fast and light.

For this test, I used a single SELECT * query on a very small table. The server was running on our old test server and the server making the requests was plugged on the same router, so there was no significant network latency due to the Internet.

The fastest solution was ngx_postgres. My 1000 times loop took 1.3 sec. The second fastest solution was lua-resty-postgres which took 1.8 sec. And then, I tested pgmoon which took 4.4 sec. I guess it was slower because it does type conversion in Lua, although I am not sure that this is the only reason.

This test was done with our Hawk authentication system.

Posted in life | Comments Off

PhpMyAdmin, I feel sorry for you…

My goodness, I have recently updated PhpMyAdmin to last version (4.1) ! What a piece of crap this became, UI wise. The team behind this project should really focus on usability instead of toying with jQuery UI widget or whatever crappy framework they use for that.

PhpMyAdmin used to be the reference in terms of good UI in the PHP 4 days. Now, PhpMyAdmin is becoming the reference for what you should avoid, unless you want to turn off your users. All these useless buttons, alerts, “ajaxified one page app” gadgets makes the application so painful to use.

I am going to stick with the last usable version if I can find which one it is (I bet I’ll find it if I grep for xmlhttprequest).

Update : Instead of searching for the last usable PhpMyAdmin version, I have installed Adminer and it seems to be enough for our needs.

Posted in php | 19 Comments

Capitole du libre Toulouse 2013

I went to Capitole du Libre this week end in Toulouse to assist the Lua Workshop 2013. It was a great event. I met Roberto Ierusalimschy, the leading developer of this little language and met all these other Lua fans. The talks were interesting, at least the majority of them.

Toulouse is really a city I like. People are friendly and welcoming. I had good time over there and hope to have the opportunity to go there more often.

Posted in life, lua | Comments Off

Install Postgresql 9.3 on Elementary OS Luna

Luna is based on Ubuntu Precise.

First follow the steps here : https://wiki.postgresql.org/wiki/Apt
But use precise instead of squeeze.

Then set a high priority preference for the new repository. I used 1000 because Elementary is 999 and apt-get -t only goes to 900 which was not enough.
See : http://wiki.postgresql.org/wiki/Apt/FAQ#I_want_only_specific_packages_from_this_repository

Use apt-cache policy postgresql-common to make sure that the one from the new repository will be used instead of Elementary’s.

Finally, I had to modify /etc/os-release because the Postgresql install script looks for Ubuntu or Debian, not Elementary. So ID=ubuntu and VERSION_ID="12.0.4".

And it worked..!

To Postgresql packagers : please consider other ubuntu based distros (mint, elementary). It is now easier to install Postgresql on OSX than on Linux because the packages are not done correctly.

Posted in linux, postgresql | Comments Off

Problems compiling PHP 5.3.19 on Mountain Lion

I had to add EXTRA_CFLAGS = -lstdc++ -lresolv to Makefile when trying to compile PHP 5.3.19 with:

./configure --prefix=/usr/local --mandir=/usr/share/man --infodir=/usr/share/info --sysconfdir=/private/etc --enable-cli --with-config-file-path=/usr/local/php/etc --with-libxml-dir=/usr --enable-xml --enable-exif --enable-ftp --with-gd --with-jpeg-dir=/usr/local/lib --with-png-dir=/usr/local/lib --enable-gd-native-ttf --with-imap=/usr/local --with-imap-ssl --enable-magic-quotes --enable-mbstring --enable-mbregex --enable-json --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-mysql-sock=/tmp/mysql.sock --with-iodbc=/usr --enable-shmop --enable-sockets --enable-fpm --with-mhash --with-mcrypt --with-xmlrpc --enable-xmlwriter --enable-xmlreader --with-xsl=/usr --enable-zend-multibyte --enable-zip --with-pcre-regex=/usr/local --with-pdo-sqlite --enable-pdo --with-freetype-dir=/usr/local --enable-dom --enable-fileinfo --with-kerberos --with-pgsql=/Applications/Postgres.app/Contents/MacOS --with-pdo-pgsql=/Applications/Postgres.app/Contents/MacOS --with-curl --with-gettext --with-zlib --with-tidy --enable-pcntl --enable-hash --enable-mbregex --with-regex=php --enable-bcmath --enable-sqlite-utf8 --enable-intl

Otherwise I had errors with Intl (ICU) and cUrl together, something like :

Undefined symbols for architecture x86_64
_res_9_dn_expand etc...

This was on OSX Mountain Lion.
Coworker reports it also works on old Lion :p

Posted in mac, php | 2 Comments

Keyboard layout on Linux for people coming from Mac

Since I almost never used a PC before, I am a bit lost with the default keyboard layout. There is this annoying Windows key, the Alt key on the left is not the same as the right one, there is a Menu key, the Control key is very far on the right side. All in all, it’s not very well optimised, at least for programers.

Furthermore, I also recently learned touch-typing with a Bépo layout, so I don’t need to see the keyboard anymore, it’s all in my head.

So instead of the default layout, I reconfigured some modifiers keys like on the picture.

Here is the configuration I used in /usr/share/X11/xkb/symbols/altwin

partial modifier_keys
xkb_symbols "ctrl_alt_win" {
  key <LALT> {   [   Control_L, Control_L   ]   };
  key <RALT> {   [   Control_R, Control_R   ]   };
  key <LCTL> { type[Group1] = "ONE_LEVEL", symbols[Group1] = [ Super_L ] };
  key <MENU> {    [   Alt_L,  Meta_L      ]   };
  key <LWIN> { type[Group1]="ONE_LEVEL", symbols[Group1] = [ ISO_Level3_Shift ] };
  key <RCTL> { type[Group1]="ONE_LEVEL", symbols[Group1] = [ ISO_Level3_Shift ] };
  modifier_map Control { <LALT>, <RALT> };
  modifier_map Mod1   { <MENU> };
  modifier_map Mod5   { ISO_Level3_Shift };
};

It can probably be improved but it works.

Posted in linux | Comments Off

Twitter Bootstrap and the QuickForm2 Callback Renderer

I don’t know about you, but for me building HTML Forms and styling HTML Forms are maybe the most boring things in web development. It’s repetitive and takes a lot of time to do things correctly.

That’s why tools like Twitter’s Bootstrap and PEAR’s HTML_QuickForm2 can help with this part of our job.

Wouldn’t it be nice to have QuickForm2 generate a markup compatible with Bootstrap CSS, so that you could get a nice looking form without to much efforts? Well, that’s what I plan to do here.
Continue reading

Posted in php | Tagged , , , | 6 Comments

PHP with Intl and Gettext on OSX Lion

Mac OSX Lion ships with PHP 5.3.6. There are also other ways to get PHP working on Lion, for example:

These are all very good solutions, but since I prefer to travel light and the version in Lion already comes with a lot of useful extensions, I preferred to go with it.
Continue reading

Posted in mac, php | 6 Comments

From iPhone to Samsung Galaxy S2

Two days ago, I received my new Samsung Galaxy S2, which is a smartphone running Android. Previously, I was using an iPhone 3G but it really started to feel sluggish more and more with time. I was still using iOS 3 since I had no use for version 4 features and was afraid it would just make the phone even slower.
Continue reading

Posted in digital, life | 1 Comment

Getting started with HTML_QuickForm2

QuickForm 2 is a PHP library which makes the development of complex and modern HTML forms easier and faster. It is the natural successor of QuickForm with a new revamped API, PHP5 support, new features and less bloat. Its development was started in 2007 by Alexey Borzov and Bertrand Mansion, and we are very close to a first beta release. I already use QuickForm 2 in production on a dozen of sites and since its code is almost fully unit tested, it is very stable.
Continue reading

Posted in php | Tagged , | Comments Off