Case Study: The agile products and pricing engine driving all commerce at Sky and NowTV

As a mission-critical, core component of Sky’s infrastructure, powering multiple front-ends, content management systems and various routes to market, the multi-channel Products and Pricing engine handles thousands of sophisticated business rules to evaluate customer profiles and baskets. It helps Sky make the most appropriate offers to maximize long-term value for both the customer and the business. Fully data-driven, the system includes a Catalogue Services component, a powerful business rules engine, customer portfolio management, e-commerce basket and call centre support. It is optimized for speed and availability, serving tens of millions of users on a daily basis. The in-house designed business rules engine reliably handles complex dependencies and inter-relations between products, offers, discounts, eligibility rules and regulatory requirements and has had a profound positive effect on Sky’s bottom-line over the years. The engine also feeds transactional data into analytics and reporting solutions.

What was included in the scope of the project?

Spread over several modular components, the business software we developed for Sky included the following capabilities:

  • A business-friendly interface for defining and maintaining a highly dynamic product portfolio of any size as well as the scheduling of an unlimited variety of offers, pricing rules and other criteria. The interface supports complex workflows, validations and reporting;
  • A powerful business rules engine that can process customer information and run it through thousands of business rules to determine the pricing, applicable offers and a variety of other parameters for any sales transaction (for both new and existing customers);
  • The “Catalogue Services” component – a web-based API situated at the bottom of the software stack and powering multi-channel sales services and front-ends (e.g. direct / call-center, retail / partners, on-line, mobile).
  • A number of integrations with proprietary systems and third-party components, fulfillment / warehouse / delivery systems, call centre software, etc.
  • A suite of additional tools to help with customer and data migration from legacy systems; as well as bespoke data visualisation and reporting tools.

What is a business rules engine?

A business rule is a statement describing a business policy or procedure. For example: a customer can have no more than one “Sports” subscription at any time. Or: a customer buying a “Sky Sports Month Pass” in the Republic of Ireland should be charged XX Euro per month. Or something more complex like: In the the UK, all customers buying their first “Sky Sports Month Pass” in April should get a discounted rate of Y GBP per month for the first 3 months.

A business rules engine is a software component allowing staff who are non-programmers to easily add, modify or piece together business logic in whatever ways are currently required by the business. A well-designed business rules engine can help transform the entire business into a data-driven enterprise, able to respond to changing customer demands and managerial decisions in near real-time. This also means that implementing new business rules or changing existing ones requires little or no code changes.

What does the Sky business rules engine do?

The Catalogue Services engine exposes data-driven REST API end-points, which other components use to answer questions, such as:

  • For a given customer (or territory / market segment), what products are currently available for sale? What prices can Sky display for these products?
  • For a given customer and a selection of products, is the selection valid, given Sky’s current policies, promotions and restrictions? How much should the customer pay up-front? What will be their recurring (monthly) charges? What currently available offers and discounts are they eligible for?
  • Once they place an order for the products in their basket, what should the customer actually receive, in terms of order fulfilment? What needs to be shipped and when? What services need to be enabled, disabled or modified in their account?
  • If an existing customer subscription needs to be renewed soon, how much should they be charged? Are there any known price changes coming up? Any upcoming changes to the offers they are eligible for?

Technical details

The software is written in pure Python with a bespoke, high-performance in-memory graph database and business rules engine. The Python Flask web framework is used to expose a number of REST-ful APIs to the other micro-services components in Sky’s tech stack and to various client-facing front-ends. It uses the Kubernetes container orchestration system to run on Sky’s proprietary cloud infrastructure and on Amazon’s AWS cloud.

Python was initially chosen because it provides a way to quickly and easily build a working prototype that can be tweaked at will without a large commitment of resources. Because Python code is generally compact and easy to understand, it made it possible for team members from different backgrounds and departments within the business to review and contribute. As the software grew and was deployed to production (with a comprehensive test framework and an automated CI/CD delivery pipeline), Python proved to be reliable and flexible enough to take on all of the expected production load. With occasional small tweaks and performance improvements, the software has been able to handle all spikes and business-driven increases in traffic that have been thrown at it.

A further comprehensive suite of non-functional performance and reliability tests now ensure that the platform can safely handle at least an order of magnitude increase in the volume and frequency of requests it receives. The average response time for all API end-points exposed by the system is under 100ms, including network latency, data lookups and all the complex business logic that takes place under the hood.

More importantly, because well-structured Python code is easy to refactor and maintain, the entire platform was able to be developed, maintained and enhanced over the years with a team of no more than 5 core developers at any given time.

International on-line expansion

Around 2016, we further re-purposed the same platform for international use by Sky’s new on-line brand – NowTV. The software was enhanced to handle multiple currencies and support millions of new customers in new territories. Thanks to the agile, modular design of the software it was easy to implement significant functional and performance improvements to ensure the new brand could hit the ground running and meet growing on-line demand for OTT streaming media.

Following the success of the Product and Pricing Engine and the Catalogue Services components we created for Sky, our new role was to re-design, optimise and continuously enhance this solution to power all of commerce across multiple territories and partner channels for NowTV. We further created tailored tools in Python to migrate over 12 million existing UK customer accounts to the new platform.

The new, expanded software provides a dynamic view of NowTV’s product and offers catalogue, adjusted for any territory, sales channel, route to market, customer group or even for individual customers. It can also evaluate any target basket selection and determine the customer’s eligibility for all required products, as well as any applicable manually-selected or auto-applied offers. The APIs can then annotate the customer’s basket selection with the correct pricing information, discounts, credits, rewards, vouchers, recurring and non-recurring payments, legal key facts and the results of any other business rules that were applied.

Buying software vs investing in your own software assets

Buying software for your business and paying for a zoo of on-line services is an overhead expense. You’re spending money, time and energy. Your goal is to to minimise that. On the other hand, when you are investing in building your bespoke, unified business software platform – you are creating an asset. It’s a competitive advantage, which helps you focus on your growth while yielding increasing ROI day after day. Your goal is to do more of this.

Now more than ever it is practically impossible to do any kind of business without relying on multiple pieces of software and on-line services. At a minimum, your business is probably using software for invoicing, business accounting, payroll, a CRM system for managing client data, another system for supply chain management, a place to store and organise various documents and archives, a place to manage social media and your digital assets (like your website), perhaps you also use e-Commerce services, communication software, customer support ticketing, tools for managing inventory, scheduling, appointments, time-sheets, and so on.

Perhaps a lot of this goes in Excel spreadsheets or something else your staff has hacked together. Some of this software is probably free, some you’ve paid for, some is a recurring monthly expense (whether for licensing or for access to on-line services). Perhaps you’re even paying for professional, integrated solutions from the likes of SAP, Oracle or Microsoft. The point is – all of this software is overhead. It’s an additional expense, which your directors have a duty to continuously try to minimise, because less expenses means more profit. While some of these expenses might be relatively trivial, professional business software can be incredibly expensive.

Unless you know what you’re doing.

The key shift in perspective, which literally sets apart all modern successful businesses, is the realisation that investing in their own, tailored enterprise software platform specifically designed from the ground up to support their unique set of activities and their corporate culture leads to the creation of their most valuable digital asset. It is the only investment that can simultaneously:

  • Cut costs and optimise performance;
  • Enhance the capabilities of the business and its capacity to deliver;
  • Become the secret sauce of your business, leading to unbeatable competitive advantage in an uncontested market space;
  • Increase in value exponentially as a function of the business growth rate.

Your bespoke business software platform is your most valuable intellectual property. If designed well and nurtured as the company grows, it will inevitably expand to contain the most complete and detailed blueprint of all operations and business processes – the set of activities that make your business unique and different from the competition.

Imagine someone is interested in acquiring your business. All the money you’ve spent and continue to spend on loose pieces of software goes on the expense side in their calculations. It’s unattractive.

The money, time and expertise you have invested in your own software platform, on the other hand, now looks like pure gold at the very core of your business, dramatically increasing your valuation.

The foundation of a successful business software platforms is a good database

Your database system helps organise, unify and simplify key business data and processes. It is the foundation of all proprietary software assets. As a business owner or decision maker, you should know what makes a good database and how to make informed decisions when it comes to choosing a database management system.

The most commonly used type of database (and probably the most appropriate for most business needs) is what’s known as a “relational” database. This refers to the way data is organised within the database in a way that groups related data together into “tables” and makes it easy to explore the links (or relationships) between different groups of data. When you have your business data stored in a relational database, you have the power to define, manage and report on many different types of relations from one type of data to another. The standard for querying relational data is called SQL – the Structured Query Language, which is one of the greatest tech skills any programmer OR business person can invest in learning.

Any relational database worth using in a business context must be ACID compliant. In simple terms, this means when you put some data into it, you can have full confidence that your data is not going to get lost or corrupted – it will be there, intact, whenever you need it, even in the event of power failure, server break-down, etc.

Of course, this doesn’t guarantee that the software accessing the database can’t damage or loose the data because of software errors or malicious attacks. To safeguard against this, you need a robust and consistent data back-up strategy, secure access control and a safely stored audit trail. These are all things that a good database should support or make relatively easy to implement.

Unless you are already burdened by existing licensing restrictions and contracts, the one database management system we always recommend using is the open-source PostgreSQL database. With over 30 years of active development, PostgreSQL is an industry-standard database complying with all important standards. It has been proven to reliably handle tremendous amounts of data with outstanding performance in a huge spectrum of business and scientific contexts all around the globe.

Many of the most successful on-line businesses rely on PostgreSQL for storing and managing transactional and reporting data. Thanks to its user-friendly design and comprehensive, accessible documentation, PostgreSQL is easy to get started with and entirely suitable for 99% of all data management tasks we have ever encountered in a start-up or an SME. Moreover, it is a safe choice for supporting fast-growing businesses because it is easy to scale – especially with managed cloud solutions like Amazon’s AWS RDS or Aurora, both of which have native support for PostgreSQL.

AWS RDS is an Amazon cloud service that allows you to simply choose the capacity and computational power of your database servers and you can start using an industry-grade database right away – all secured and managed for you following best practices. Alternatively, while Amazon’s Aurora service is a bit more expensive than RDS, it also gives you peace of mind with regular automatic back-ups and automatic capacity scaling, so you never need to worry about capacity planning for your database as your business grows and the amount of data you store increases to possibly unpredictable levels.

How to scale your IT for unexpected hyper-growth

When customer demand overwhelms your capacity to deliver, or pressure from investors requires you to quickly conquer new markets, having a well-designed business software platform can make the difference between tremendous success or missed opportunities.

Regardless of how well your software platform is currently performing, when a wave of new traffic arrives, either as a one-off spike, or (a quality problem to have) as a new reality for your business, your systems will all come under extraordinary stress. Whether or not this translates directly to a financial windfall or a tragic loss of opportunities ultimately comes down to one question: Is your business software platform designed to support your growth? Or is it holding you back?

Here are the basic requirements for a forward-facing, growth-enabling software platform:

  • You must have a comprehensive suite of automated functional tests for all aspects of your software, guaranteeing that you can freely and confidently break and re-build any part of it on-the-go, while keeping your production systems fully fit for purpose at all times;
  • You must have a professional suite of non-functional tests, which enable you to know (at a minimum) how your system is performing, how far it can be stretched on any dimension and exactly where the performance bottlenecks are;
  • It must be straightforward to increase the capacity of your core database on-the-go, without losing data or suffering any downtime. This is where managed solutions like AWS Aurora, which auto-scale in both computational power and capacity can be well worth the cost.
  • It must be straightforward to increase the computational capacity of your software on-the-go without interruption. “Serverless” solutions like AWS ECS Fargate, which allow you to seamlessly adjust the number of instances running your software on demand, coupled with a reliable load balancing architecture and a cloud-based content distribution network (CDN) can go a long way in supporting this.
  • To take advantage of these scaling solutions, your core software must be designed in such a way that components are loosely coupled (i.e. each component can operate sensibly on its own, without relying on other components) and are able to run concurrently. This usually means that components should not be sharing their internal state with other components, but should only interact via well-defined interfaces (APIs).
  • Reliable message queueing solutions must be part of the base software architecture, allowing incoming requests to be safely kept in a temporary queue when the platform is too busy to process them. At the same time (this is too often forgotten!), a sensible back-pressure mechanism has to exist, preventing the queue from overflowing and ultimately informing the originator of the request that the system is currently under stress.
  • Security should be part of the original design on all layers of your platform (never an after-thought or an add-on), in order to prevent malicious overloading of your systems with denial-of-service attacks.