Introducing Pylm, the library for generating components that communicate with each other

2 min reading
26 October 2016
Introducing Pylm, the library for generating components that communicate with each other
Introducing Pylm, the library for generating components that communicate with each other

BBVA API Market

All applications can be divided into their frontend and backend; in other words, what a user can see and cannot see. With the arrival of mobile devices, what is certain is that the frontend can now be a website or an app.

It is essential that the frontend should be intuitive, interactive, light and reactive. Many packages have been created to achieve this aim: Angular, Ember, Polymer and React. The model proposed is very simple: generate extensible and reusable components to develop complete applications piece by piece.

The new frontend model demands data continuously from the backend, which must be adapted to this constantly evolving environment. Work is now being done to develop the new frontend generation. The backend, which the user does not see, tends to be much more complex, as it can include old applications that must work with the new ones, public data that mix with private, etc.

Various proposals are emerging to improve this process, such as to use a microservices architecture in which each piece in the frontend communicates with an isolated part of the backend, with all its processes and data. It is an attractive proposal that reduces complexity, but involves redesigning and re-implementing much of the application, so it is not always viable.

Guillem Borrell has developed a different proposal: Pylm, the PALM implementation in Python. It is a library that generates components that communicate with each other to construct an application. It would be equivalent to having a machine capable of creating our own Lego pieces and then constructing a toy.

PALM has been designed to implement applications that receive requests via the Internet and must carry out complex and heavy calculations. PALM simplifies the process by offering patterns for generating each of the pieces (the master, slaves, web server, etc.) and connect them to each other.

One of the features of Pylm is its extensibility. In one of the first projects in which it has been used, an application that analyzes the risks associated with failures in industrial facilities, the communication flow was particularly exotic.

Based on a start message and configuration, the master sent a message to any slave, which could return one or more messages to the master, which in turn distributed more load, returning it to the slaves. In addition, most of the code written in C++ had to be recycled. Traditionally these types of application use message queues (ZeroMQ or RabbitMQ) and are implemented ad-hoc, but with Pylm the master that controls the flow of messages was configured in less than an hour using pieces already available.

Although the main aim of PALM is versatility, performance has not been forgotten. It has been used in an application as an alternative to Spark to implement a system of load balancing and the performance of Pylm was shown to be slightly better, with a shorter development time.

Some of the components of Pylm are being used in proprietary solutions by NFQ Solutions for financial risk analysis. It is free software and its first public version has recently been presented in Almeria at the last national Python conference.

It may interest you