Kong: Becoming a King of API Gateways
By Alex Kovalevych, Robert Buchanan, Daniel Lee, Chelsy Mooy, Xavier Bruhiere, and Jose Ramon Huerga
Kong: Becoming a King of API Gateways
Copyright (c) 2018 Bleeding Edge Press
All rights reserved. No part of the contents of this book may be reproduced or transmitted in any form or by any means without the written permission of the publisher.
This book expresses the authors views and opinions. The information contained in this book is provided without any express, statutory, or implied warranties. Neither the authors, Bleeding Edge Press, nor its resellers, or distributors will be held liable for any damages caused or alleged to be caused either directly or indirectly by this book.
Cover: CC0 Creative Commons, Free for commercial use, No attribution required
ISBN: 9781939902511
Published by: Bleeding Edge Press, Santa Rosa, CA 95404
Title: Kong: Becoming a King of API Gateways
Authors: Alex Kovalevych, Robert Buchanan, Daniel Lee, Chelsy Mooy, Xavier Bruhiere, and Jose Ramon Huerga
Acquisitions Editor: Christina Rudloff
Editor: Troy Mott
Website: bleedingedgepress.com
Preface
Who is this book for?
This book is useful for IT architects, DevOps engineers, CTOs and security experts willing to understand how to use Kong to create and expose APIs.
Even if you are not already familiar with Kong, it will only take a few minutes to create your first API.
What do you need to know prior to reading?
You dont need to know Kong to read this book! You only need to have a basic understanding of REST, JSON and HTTP, but you dont need an in-depth knowledge because Kongs mission is to provide easy API publishing.
You will also need a modern browser: Google Chrome, Mozilla Firefox, Microsoft Edge or Apple Safari.
The online example
All of the code for the sample project in this book can be found at:
https://github.com/backstopmedia/kong-book-example
What will this book provide?
By the end of this book, you will understand how to:
- Use an API gateway to simplify and improve the security of your microservices architecture
- Write Kong plugins with Lua
- Deploy Kong and Cassandra in a multi-region environment
- Use load balancing features.
Book co-authors and contributors
Alex Kovalevych is an experienced web developer from Kyiv, Ukraine. Having degrees in computer science and finance, he is a polyglot web developer, constantly learning and using cutting edge technologies. He has been working on different worldwide projects in gaming and health fields.
Chelsy Mooy has been handling multiple SaaS for Finance projects as a CTO and Co-Founder of PT Thunderlabs Indonesia. She believes that well-constructed technology is a powerful bunshin no jutsu." She lives in Malang, Indonesia with the dog and wears a skirt on Sunday.
Daniel Lee is a skilled engineer and is enthusiastic about tech. He really loves data science, cloud engineering, and service development. He was a former chief developer at the web community Yourssu, and now he is running a legal tech startup, Dbrain Science, in South Korea.
Robert Buchanan is a passionate, forever learning software craftsman that picks the right tool for the right job. He is a polyglot engineer who has been in all aspects of the cycle as a UI developer, service developer, cloud engineer and performance analyst. He lives with his wife and kid in Northern Kentucky, United States.
Xavier Bruhiere is a senior data engineer growing the Kpler team in Singapore. He has been crunching data since founding his own quantitative investment company and through startups in Paris. He loves to collaborate with smart people, visiting new countries and eating Italian delights.
Jose Ramon Huerga Ayuso is an API Management and Microservices expert. During the 80s he was a teenage programmer and later in the 90s he earned a degree in computer science. He has been working in multiple fields, including SOA, QA, ECM, and CRM. He lives with his wife and two kids in Madrid, Spain.
Technical Reviewers
We would like to the thank the following technical reviewers for their early feedback and generous, careful critiques: Nicolas Huray and Michallis Pashidis. Thanks also to Eber Herrera, Panagis Tselentis, and Damian Czaja.
Chapter 1. Microservices architecture
Have you ever thought about marching bands? There are groups of brass players, woodwind players, percussion players, and color guards that join together and play their role without being dependent on each other. Any individual player can be replaced or upgraded without disrupting the entire instrumental section.
Microservices are like this: any one part can be replaced without breaking down the entire system.
Lets take a cinema system as an example. You can always check which movies are showing. You can also check if the movies have been well reviewed, you can reserve a ticket (or two), and you can be notified when new movies are showing (of course, in your favorite genre). As the requirements grow, you can add more features like blacklisting users, or embedding a payment gateway that helps customers when paying for tickets. But in this scenario you have to test the whole system to make sure that changes dont affect other parts of the system, and you need to take the system offline when making upgrades. With microservices, however, you dont need to test the entire system and you dont need to take it offline.
Monoliths most popular patterns in view of Microservices
There are several design patterns used in a monolith architecture to scale up the system. The most popular patterns are three-tier architectures and MVC. In microservices both patterns are used in order to build a single service or to compose services.
Three-tier architecture
Three-tier architecture separates development based on three layers:
- Data Access Layer (DAL) is a layer where we define our entities and their relationships. This is the core of the whole system. Because of the core word, this is the last layer that should be changed or modified.
- Business Logic Layer (BLL) is where we put business policies and workflows. It controls whole business events and their responses. Because policies and workflows change from time to time, this layer should dynamically change.
- Presentation Layer (UIL) is the upper layer that is seen and interacts with the end user of an app. This layer is dependent on devices, whether they are desktop apps, web apps, or mobile apps.
Three-tier architecture is used to better maintain processes. This architecture is commonly modified and used in microservices. For example, you can put a data access layer and business logic layer in a service level, and the presentation layer in the client level. In the other example, implementing three tiers in level of services, clients only need to fetch requests to display views. This second option is not frequently used.
MVC architecture
Model-View-Controller (MVC) architecture is widely used in popular web-based frameworks like Ruby on Rails and Laravel. Model represents the Data Access Layer and the Business Logic Layer, while View and Controller represent the Presentation Layer. Just like with three tiers architecture, the MVC architecture is often modified and used in microservices.
Microservices answer
Using microservices is not only about chunking the monolith into pieces, because the whole mindset is different. It is much more than just separating layers. Some microservices characteristics may help explain what microservices can and should be.