Enterprise

Fabulous Fortunes, Fewer Failures, and Faster Fixes from Functional Fundamentals

In this video, Scott Havens, the Senior Director of Engineering, Head of supply chain technology, at Moda Operandi talks about the importance of functional programming.

This video will also help you in understanding how real-world enterprises adopt functional programming principles to achieve greater resilience. The functional programming principles can be adapted easily to their line of business to enable faster time-to-delivery and also to lower the total cost of ownership.

Functional programming principles not only apply to a small program but can be applied at a larger scale. In this video, Mr.Scott talks about the fortunes, failures, and the faster fixes that are possible from the functional programming fundamentals.

Item-availability at Walmart

At 13:02, Mr.Scott briefs about the factors that go into ‘item availability. The different factors impacting the item availability include warehouse inventory, reservations, store floor inventory, sales caps, backorders, item eligibility, warehouse eligibility, third-party inventories, and legacy systems.

At 14:52, He illustrates how the architecture of an inventory system at Walmart functions through a diagram. The website calls the ‘item availability API. This in-turn calls the global item availability API that checks its cache. If the item isn’t available in the cache, it falls back to the other services. The architecture is composed of multiple systems with each system consisting of its own business logic.

At 17:20, the presenter explains that every system component is tightly coupled to other systems. This makes the testing process extremely difficult. Unit testing will only be converting a tiny fraction of the space of potential errors. Completely relying on integrating tests for a complex system is absurdly costly and ineffective. In addition, each of the system components was fundamentally designed internally in a traditional manner.

As the changes happen the current state stored in a relational database is mutated in place. This is where functional programming comes into the picture. When the functional programming is implemented effectively, we can reduce the service calls to a greater extent with very minimal downtime and at a very good latency rate.

Effectiveness of functional programming with proper design principles

At 25:16, Mr.Scott mentions that Walmart is currently using the azure cosmos DB change feed while Moda uses Kinesis streams. He begins to illustrate how the design function would function. The two important principles of design functionality include immutability and purity. Immutable messages are received over Kafka that are in turn consumed by micro-service running stateless domain logic.

This in turn emits immutable events into data streams. The events are then published downstream to any consumers over Kafka. Computations can be isolated from the real world. The third principle of design functionality is ‘Duality of code and data. Real-time computation can be replaced by data lookup wherever feasible.

At 27.21, the speaker talks about the ‘Panther’ team at Walmart. This team was one of the first teams to use the design functionality pattern extensively. Panther is an inventory tracking and reservation management system. On the supply side, this system is responsible for aggregating and tracking all inventory sources. On the demand side, this system acts as a source of truth for reservations against the inventories at the warehouses. At 28:03, Mr. Scott lists the primary functional goals of the ‘Panther’ team.

The goals include maximizing availability, minimizing reject rates, enhancing insights, unifying inventory management, and improving customer experience. Some of the non-functional goals of the team included high availability, SLA-backed performances, and geo-redundancy.

At 30:45, the presenter talks about how item availability can be achieved through event-driven architecture. He adds that the message streams can be used to invert the dependencies instead of dependent service pulling the required inputs in real-time. The source system can push the data changes. The dependent service consumes these changes as and when they happen.

The changes are then pushed to the down-streams. Thereby we can convert from a primarily synchronous service-oriented architecture to a primarily event-driven architecture. With this new event-driven architecture, an SLA of 99.98% uptime at 300 ms was achieved with only two service calls.

Conclusion

At 35.00, Mr.Scott concludes the presentation by mentioning some good practices and ways for proper functional programming. It is always recommended to eliminate one dual write and start practicing property-based testing. Always try to switch one web service to also publish events wherever feasible. It is not necessary to completely commit to event-sourcing.

Publishing the changes as and when they happen is sufficient. Later you can go ahead to switch one consumer to read the events instead of making HTTP calls during runtime. In this video, Mr.Scott covers the concept of functional programming, design patterns, the architecture followed by the ‘Panther’ at Walmart, and the best practices to avail the benefits of using functional programming.

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button