Managing concurrencyMonday, April 23, 2012 14:21

 One important question in web applications that share resources as database is solving concurrency problems. Very often it happens that one actor can change resources already modified by other actors, in a way that is no evident client-side. Lets assume that two operators, Alice and Bob, try to assign a value to a field F. If concurrency is not treated and Alice wants to set a value X, while Bob wants to set a value Y, the first update is lost, so the last updater wins. This problem is defined as "lost updates". In order to avoid lost updates, there are two ways: pessimistic lock and optimistic lock.

When using pessimistic locking, a web app designer is pessimistic about the chance that at the same time two operators would like to change the same record in a database and so it locks the access to the resource until one operator has finished any change on it. This technique is a bit difficult to implement and needs to rely on database locking features.

When using optimistic locking, a web app designer does not lock the record until it is modified. In order to avoid "lost updates" problem, at every change of a record it is necessary to verify if it has been modified in the meanwhile. If this is true, the update command has to fail and the user should receive a notification with the updated field. This can be frustrating for the user but avoids lost updates without interfering with the ability to see resources. This pattern has be implemented in a simple way in Ruby on Rails.

Pessimistic locking is more effordable, but it constrasts concurrency, reducing efficiency on the system. Optimistic locking is more appealing when there is a lot of concurrent calls, but can be frustrating. In my opinion, your choice depends on what type of web app you are building.

Categories: misc, progr

Comparing PHP frameworks: Yii is the winnerMonday, April 16, 2012 16:45

 Recently I started a comparison of php frameworks on the web. I searched a framework based on MVC pattern, easy to understand and modify, very flexible, including more recent development in ajax technologies. I found yii framework as the winner.

What I think really impressive is the following sketch taken from http://www.yiiframework.com/performance :

Now I am really happy for this choice. I found yii perfect for my needs. Here is my original doc.

Categories: php, yii

Setup openafs client and kerberos on Ubuntu lucidMonday, April 16, 2012 15:59

In my working organization I often need to login to openAFS through my Ubuntu box. As www.openafs.org says, AFS is a distributed filesystem product, pioneered at Carnegie Mellon University and supported and developed as a product by Transarc Corporation (now IBM Pittsburgh Labs) and offers a client-server architecture for federated file sharing and replicated read-only content distribution, providing location independence, scalability, security, and transparent migration capabilities.

In order to install openafs client:

sudo apt-get install openafs-client krb5-config krb5-user libkadm55 openafs-krb5

The first package is the standard openafs client that lets you connect to a default cell, configurated in /etc/openafs/CellServDB, the others are related to kerberos 5 authentication, configuration in /etc/krb5.conf.

Depending on different configuration, the Ubuntu box lets you obtain AFS tokens in different ways. The preferred one for me is the following

kinit <username>

and you are prompted for password for you default kerberos domain (usually in all uppercase characters). In order to see if you are logged in kerberos realm issue:

klist -5f

In order to get AFS token through kerberos ticket:

aklog -c <afs_cell> -k <kerberos_realm>

In order to verify if you get the AFS token, please issue:

tokens

With these simple commands you should get your afs client working with Ubuntu.

Categories: afs, ubuntu

Who I amMonday, April 02, 2012 15:04

I am Angelo Mariano and this is my blog.

I am a researcher and ICT technician.

I started my professional life as a software developer in 2001. I started with Java and databases on handheld devices. I worked as a consultant for IBM in several wireless and web java-based projects.

In 2004 I took a PhD in Theoretical Physics, treating decoherence in quantum mechanics.

In 2006 I merried with my lovely Rosangela

In 2007 I became a consultant for a global e-learning provider and managed several project across ICT and learning platforms.

In 2009 I became dad of two cuties, Mattia and Chiara

In 2010 I became an ENEA (Italian Agency for New Technologies) researcher in the ICT department, administrator of CRESCO/Eneagrid cluster in Brindisi, Italy.

I know Java, PHP, Ruby, Javascript.

Categories: misc