Jonathon McMurray
Last month, Gary posted a blog offering us a timely reminder that it’s always worthwhile reviewing our kdb+ architecture, and promising a series of monthly installments about different aspects of maturity for kdb+ applications. Here, we’ll look at the first of those maturity characteristics – the kdb+ framework.
We’ll discuss what a kdb+ framework is (and isn’t), the benefits of using one, typical features, some examples and we’ll finish up with some red flags – what to look out for to keep your kdb+ journey plain sailing. Along the way we’ll also discuss the merits and pitfalls of incorporating non-kdb+ technology into a kdb+ framework.
In general terms, a Software Framework is software that provides generic functionality to allow developers to more rapidly develop applications by only writting additional application-specific code. Naturally, a kdb+ framework applies this same principle to kdb+, providing generic functionality that can be used by developers to build kdb+ applications more rapidly. The framework by itself doesn’t “do” anything, it is the application built on top of the framework that serves a business purpose.
There are two main components in a kdb+ framework; default or template processes, and library code. Additionally, a framework will have it’s own paradigms and standards for concepts such as code organization/layout and configuration.
A default process is a ready-built component within a kdb+ framework, that implements a common process type found in kdb+ systems. A very common example of this would be a tickerplant, which will be at the heart of many kdb+ systems. Generally speaking, a framework is likely to have a number of such default processes which can be used “out of the box” in an application built using that framework – different frameworks will have different ways of configuring which processes should be included in your application.
The framework should also provide convenient ways to customise the default processes at the application level – both in terms of modifying configurations, and by modifying or extending behaviour through the loading of additional code. The mechanisms for doing this will vary by framework.
Of course, in the vast majority of applications, additional custom processes will be needed as well as the default processes.
The other key component in a kdb+ framework will be library code. This is code that can be loaded and used in any process within the framework – often some will be loaded by default in every process of an application using the framework, while other libraries may only be loaded on-demand. Common examples of library code that frameworks will provide include logging, timers (extending kdb+’s single timer function), connections (allowing processes within the application to connect to each other without hardcoded hosts & ports etc.) and numerous others.
Often there will be dependencies between included libraries, and frameworks should provide a mechanism for specifying dependencies/load order to account for this.
As a general rule, any generic functionality (useful to many apps) will likely be in the framework and anything specific to the business application will be in the application.
Where the team developing the framework is also developing an app using the framework, this may make things less clear as to where a particular piece of code should be placed – a good rule of thumb is to ask “Would this be useful to other apps?” and if so, place it in the framework.
Remember that a framework by itself won’t “do” anything – it just provides the building blocks that an application will put together and expand upon.
There are a number of advantages to using a kdb+ framework to build an application:
Below is a list of what could be considered key features of any mature, robust kdb+ framework
Some frameworks are publicly available, and can be used by anyone (some are free of charge, some are for paying customers only). Others are specific to a particular organisation, and kept privately within that organisation.
There are a few main public frameworks available:
Beyond this, many of our clients have their own, internal frameworks used across various apps within those companies.
Some frameworks are purely (or mostly) kdb+, with all default processes implemented in q. Other frameworks will make use of other existing technologies for various components.
For example, a common component of kdb+ frameworks will be a discovery service, allowing processes to connect to each other without using hardcoded hosts and ports. This can be implemented entirely as a q process, with that q process keeping track of all running processes within the application & providing this information to other processes as needed. Alternatively, a non-kdb+ specific discovery service (for example, https://www.consul.io/ ) could be used, generally with a q library to interact with the service. This could simplify q processes finding non-q processes within the application and vice versa, if that is applicable.
There are some pros to each approach, shown below:
kdb+ only | Incorporating other tech |
---|---|
Simplify tech stack – knowing kdb+ allows inspection of full framework
Simplify deployment – only need to deploy q & the application, no external libraries, apps, runtimes etc. Tighter integration with framework |
Can use well-known, battle-tested components, rather than re-implementing functionality in q
May allow better interoperability with non-kdb+ applications Quicker framework development if only a simple wrapper library required |
There are a number of potential red flags when it comes to kdb+ frameworks, a few of these are listed below:
Hopefully this blog has been helpful to you and will be a valuable tool as you evaluate kdb+ frameworks for future applications, or consider “framework-izing” code already in use in your application, for the benefit of other teams within your organisation. If we can be of any assistance to you in this area, please get in touch – we’d love to work with you and give more tailored advice for your specific use case.
The next step on our journey through kdb+ application maturity will be released next month – keep your eyes peeled!
Share this: