Posts fromNovember 2008

Profiling PHP Applications

We at codecentric are not only leaders in Java performance, but support our clients on a variety of software development challenges.

I posted in a previous entry about Comparison of PHP and Java. I said that PHP mainly lacks appropriate tooling to develop debug and maintain. To be fair with PHP this posting will today describe how to profile PHP applications to tune performance. We will see how this tooling compares to the Java ones.

For Java developers JProfiler should be a well known tool for profiling and analyzing performance of Java applications. De equivalent in PHP is called Xdebug Xdebug + CacheGrind. Xdebug is recording the calls to the PHP scripts, while WinCacheGrind is then used afterwards to evaluate the collected Data. In this example we are goung to profile a command line call of the symfony Framworks. Because I am commiter for this framework, I use Xdebug from time to time to ensure a good nonfunctional quality.

First you need to download the appropriate ‘.dll’ (or ‘.so’ for Linux) extension from the Xdebug website and put it to the other extensions into the ‘php/ext’ directory. To enable tat extension you need to add Xdebug to the ‘php.ini’ Xdebug and tell it where it should put the profiling results:

zend_extension_ts="d:\dev\php\ext\php_xdebug-2.0.3-5.2.5.dll"
xdebug.profiler_output_dir="c:\xdebug-profiling"
xdebug.profiler_enable=1

Take care to edit the correct ‘php.ini’ file. There is one for the command line calls usually found in the PHP directory and another one in the Apache directory for the PHP processes spawned by Apache. Additionally you need to create the target directory first because Xdebug will not create it if it is not existing yet.

Invoking ‘php -m’ from the command line should output something including:

[Zend Modules]
Xdebug

Now we are going to profile a simple call. For example one to the symfony sandbox to create an application:

php symfony generate:app codecentric

After this call has ended an 8MB ‘cachegrind.out.4896′ been created for us. It now can be loaded using WinCacheGrind, which looks like this:

Unfortunately WinCacheGrind has only limited functionality. KCacheGrind allows some more settings and graphical representation of the data, but also is not as complete as the Java tools we usually use. It also does not contain a memory view, which might be due to the fact that the PHP memory management is pretty messy. Quite useful though is is the timing information displayed.

On the ‘Overall’ tab you can find code which took in sum the most time of your application. This is usually the code where you can make the easiest improvements. For the symfony task we can find here the following:

Function  : sfFinder->search_in
Avg. Self : 0,2ms
Avg. Cum. : 5,1ms
Total Self: 127ms
Total Cum.: 3214ms
Calls     : 629

you can see that the search_in function takes an average of 0,2ms, but methods invoked by it add another 5,1ms in average. Because this function is called 629 times, this gives you the total time spent. A good candidate for checking if it really should be called that often, and if yes, if a single call can be made slightly faster.

As you can see, also without a lot of expertise for performance issues, one can use above described tools to optimize PHP application performance. Perhaps in some time in future PHP and its tools will be as sophisticated as it is already today status quo in Java.

Fabian Lange

 

codecentric @ W-Jax 2008, Day 2, Nov. 05, 2008

Today we have the second day of W-Jax 2008 in Münich, the leading conference für Know-how in the Java-Space. The conference adresses developer, project leader and architects and deals with the main aspects of successful enterprise projects.

Our consultants and developers attend this event to get updated on current technology trends, strategies and the usage of the respective technologies.

Please find the following collection of speaker slot and session abstracts of the second day

Portal 2.0: Bringing Social, Web 2.0 and SOA together for the Enterprise (Brian Chan)

The keynote of Brian Chan showed several examples of customer websites that use Liferay. Opposite to his presentation on the Jax 2008 Brian Chan did not present new information about Liferay. The Jax 2008 presentation was far more “code-centric”. The typical infrastructure; blogs and wikis of modern companies have been showed with their individual advantages.

Brian Chan is a sympathic, easy guy with passion for social networks and is leading the architecture section at liferay.

Die Keynote raised less question because Liferay is in either case a worth seeing product and in the keynote systems using liferay were well presented.

Altogether a nice keynote with less new information.

Conclusion: Worth a view on it!

Marc van den Bogaard, IT Consultant @ codecentric

Batch-Processing with Spring Batch (Agim Emruli)

“Batch processing is not a very popular subject” (cites, Agim Emruli from SpringSource). Although processing of sequential, non-interactive tasks is very important for many applications.

Conversion, validation, extraction, update and export are typical tasks of a batch process.

The requirements are:

  • High throughput of data
  • Self controlled) restart
  • Sequential process
  • partial, parallel processes

Therefore, Spring Batch delivers a lightweight framework to fulfill all those requirements.

Batch processing in the manner of Spring Batch looks like follows. A batch job has one or more batch steps which process some again and again:

  1. The ItemReader reads the input from a source
  2. The ItemWriter processes this read object and persits it somewhere

Such a job can be started in different ways. The commandline, quartz or JMX are only simple examples to do this.

Conclusion: Spring-Batch is a simple and good framework, which make it easy do implement sequential, often uses processing. And: It is the only OpenSource framework available for those jobs.

Thomas Bosch, IT Consultant @ codecentric

Business processes and rules with jBPM & Drools – an unbeatable team (Bernd Rücker)

JBoss developed two libraries that provides BPM (Business Process Management) and BRM (Business Rules Management) – jBPM and Drools.

With JBoss jBPM you can easy declare an oriented graph that define a process. Such process passes through the graph node after node. This makes it easy to define an extensive workflow for your business process.

JBoss Drools is a rule engine, that enables you to define business rules in a declarative way. At a certain point of time the working memory of drools is filed with data before the rule engine fires all his rules from a defined ruleset. After this the result than can be handled.

With the use of Drools you can easy show and discuss complex rules with people from the department. It is possible to create rule files with Excel and to import them in Drools.

The decoupling from the rest of the business code is the big advantage of those rule engines. With this you can easy maintain and change rulesets during the runtime of the application.

Conclusion: Drools provides a good solution for defining business rules. But I can’t see the strength in combination with jBPM.

Thomas Bosch, IT Consultant @ codecentric

Tim van Baars

 

codecentric @ W-Jax 2008, Day 1, Nov. 04, 2008

Today is the first conference day on the W-Jax 2008, the leading conference for extensive expertise in the Java environment. The conference addresses software developers, project managers and architects and deals with the most important aspects of successful enterprise projects.

We use the W-Jax as a forum to communicate and network with our clients, potential clients and partners. On the following pictures you can see our booth with our areas of expertise performance, architecture and open technology. For those we provide specialized consulting and services. Our booth is located at the entrance to the exhibition area and is well attended. Alois Reitbauer from our partner dynaTrace software comes along after his speaker slot “Architecture: Notes on Java Database Access” and we talk about current topics. Opposite to our booth Sun Microsystems is located that presents OpenSolaris, Glassfish, MySQL and OpenOffice.

Our consultants and developers attend this event to get updated on current technology trends, strategies and the usage of the respective technologies. Following the conference the attendees present the information to our other colleagues of codecentric mainly on our Friday meetings. After that the technologies are tested and reviewed on suitability for potential practical application.

A selection of the visited speaker slots and sessions

Architecture Notes on Java Database Access (Alois Reitbauer)

Contents of the speaker slot were the most common problems and solution strategies in the context of database applications. Apart from specific problems in connection with databases there were also specifically the issue of lack of performance tests raised. Interesting was that at least nobody raised his hand on the question who is performing regular performance tests in their daily work.

Also in our study on “performance in the Java environment” which we have carried out on Jax 2008 in Wiesbaden in April 2008, missing performance tests were often mentioned. But here is the paradox that many of the attendees assess databases as a problem, but no time and money are invested by companies in prevention. It would be very interesting to find out where the reason for this contradiction lies.

One of the reasons might be, that often little or no performance tools in the company are in use. Due to the lack of knowledge, appropriate approaches and processes for performance measurements a proper use of the data to achieve improvement are often missing.

Tim van Baars @ codecentric

The Future Of The Web – Html 5, WebSocket and Comet (Jonas Jacobi)

Real-time Web application requirements are always in demand – the extension of AJAX is called AJAX Push with Comet and WebSocket. While the classical AJAX requests come from the client, AJAX offers the possibility to use the server as the initiator of a communication.

A popular example:

While you look on a stock exchange website, the stock quotes of the shares appeared are updated regularly, without prompting the user to refresh the side regularly

With WebSocket a long time connection to a server is established on which then in both directions (full-duplex) can be communicated. Both the client and the server can send information to its counterpart, so that even with WebSocket real-time requirements can be served.

Conclusion: Realtime updates of websites are nice features of an interactive web. Now it is possible for the server to update its site at the client without the client beeing involved.

Thomas Bosch, IT consultant @ codecentric

Advanced JPA with EclipseLink (Doug Clarke)

EclipseLink is an open-source implementation of JPA. It emerged through a port of Oracle TopLink. Toplink itself is again available as commercial solution. Besides supplying a reference implementation for JPA, EclipseLink provides a layer over a range of data sources and allows additional XML and EIS persistence.

Compared to Hibernate, that provides a caching mechanism through third-party technologies, EclipseLink has its own caching solution.The market penetration of EclipseLink compared to Hibernate is rather low. In the web you can find lesser pages about it and there are only a few useful information available about EclipseLink. The additional features such as XML Persistence are also provided by e.g. Hibernate, so it is questionable whether the additional features cause the customer to decide otherwise.

Conclusion: Further Observation!

Do it asynchronous: Events und Messaging in Enterprise Architekturen (Jens Schumann)

A decoupling of components can be easily realized by asyncronous communication.

Events and messaging offer such opportunities, though not necessarily required to be asyncronous. Such messaging or event-driven architectures scale very well and can be perfectly used in congested applications.

Events are mostly used for process monitoring. Within high throughput they offer the opportunity of aggregation of information, selection and its monitoring.

Messaging, however, tend to be used for process steering. Messages sent through such channels, contain in their content part mostly information that are directly interpreted by the recipient.

This different with events, which are usually only defined by their type, so that the recipient’s reacts on an event-type response and not its content.

Conclusion: Events and messaging are, in my view good alternatives to decouple components from each other and are a good approach to achive high scalability.

Thomas Bosch, IT Consultant @ codecentric

JavaFX – Java goes RIA (Lars Röwekamp)

JavaFX is the designated successor of Sun’s Swing. The big advantage over Swing is the declarative syntax, which allows to develop by relatively few lines of code a GUI application. JavaFX is a DSL (Domain Specific Language) that has been optimized for the development of graphical user interfaces.

Code-Example:

import javafx.ui.*;
import java.lang.System;
Frame {
    centerOnScreen: true
    visible: true
    height: 50
    width: 350
    title: "Hello codecentric application..."
    background: yellow
    onClose: operation() {System.exit(0);}
    content: Label {
        text: "Hello codecentric"
    }
}

This creates a frame with a simple “Hello code centric” label

Key features of JavaFX – in addition to the declarative syntax:

  • functions are objects of a class so that they are also assigned to variables and can be passed over as a parameter of another function.
  • sequences. They can be better seen arrays will serve the mapping and a set of objects, which are many and varied and can be changed
  • The so-called binding offers the possibility of an expression of a variable or another variable “direction”. When these changes linked to the outcome variable or expression of the value of the variable re-set
  • components of JavaFX are wrappers for Swing components, which Simplified possess UI API
  • For graphical elements are Scene graph – a Java2D wrapper. This can produce effects such as lighting effects, timelines or transformations on objects implement JavaFX
  • For designer surface, there are plug-ins for Adobe graphics tools, such as Illustrator, allowing a simple separation between the Obeflächendesign and the business logic to achieve

JavaFX is currently still in a preview status. In mid-2009 a complete first version is planned.

Conclusion: From my perspective, JavaFX now offers the possibility of a simple way to develop GUIs. The great strength is also the possibility to develop logic and design separately by using graphical tools.

Thomas Bosch, IT Consultant @ codecentric

Tim van Baars

 

Ajax World Conference in San Jose, CA

From the 20th to 22nd of October the 6th Ajax World Conference took place in the sunny San Jose, CA. I was there those 3 days as delegate of codecentric to catch up with the newest trends and developments in Ajax and RIA.

I tried to collect and write down all the impressions I got during the conference in the attached slideset. I really hope I managed to write everything down in a comprehensive way. In general the wholistic presentation on RIA, AJAX and web 2.0 was very interesting. Not only the technical talks, but also very enterprise business oriented sessions were a pleasure to attend. It really shaped my understanding of the state of the art today.

I met many interesting and friendly people there, learned a lot about JavaScript and frameworks and also collected good arguments for implementing features in “new” technologies.

In case of any questions on the conference, my slides or RIA in general, do not hesitate to contact me.

Fabian Lange