[Translation] How is Mashape management 15,000 APIs and micro-service (3)

https://stackshare.io/mashape…

Scaling Challenge

In 2013, when a large number of When the running third-party API was added to Mashape’s market, we encountered a scaling problem.

In July 2012 and July 2013, our number of APIs increased by 50 times.
http://i.imgur.com/0JaNhEM.png

Not only is the number of requests through our agent skyrocketing, Mashape starts to manage more than others Market more APIs. At that time, the market had 3,500 public APIs that needed his management.

The API market needs rapid expansion. Our API proxy is built with Node.js, and the backend is built with heavy-duty Java. It is a monolithic application architecture, and our Node.js agent cannot handle large traffic spikes.

At that time, it was often necessary to work overtime and consumed a lot of AWS resources. Our bank account has lost a lot of money, and the CEO has lost a lot of hair.

We need to find a solution to handle large traffic, while ensuring reliability and safety. We want to move from a single application to a more flexible way.

http://i.imgur.com/C75mgO7.png

We have always wanted to create our own API gateway; the goal is the following Content:

  1. Predictable stability in months and years, not days.

  2. Easy to expand in multiple geographic locations and maintain high efficiency, and with minimal overhead.

  3. Achieve componentization and easy expansion through some simple plug-ins.

  4. Independent: Support various environments, frameworks and languages.

  5. It can be easily configured using RESTful API.

Basically, it is the “ElasticSearch” of API management. Our CTO started looking for a solution, and met a CloudFlare engineer by chance, and brought us into the magical OpenResty world. Building on top of Nginx allows developers to extend Nginx functions with Lua, which is an embedded scripting language used by many high-traffic websites.

CloudFlare uses Lua scripts to build security and caching. I think we can do the same thing, just focus on API and microservice management. Nginx has been recognized as a stable and trustworthy HTTP server, which is very suitable for our original needs. After using OpenResty, we started to build Kong.

The birth of Kong (API gateway)

In 2013, Mashape used Nginx/OpenResty to implement the API release function on the market. Billing, authentication, flow control and rate limiting have become custom OpenResty plugins written in Lua. We call him Kong (yes, like “King Kong”, like our own name: MashAPE).
http://i.imgur.com/2azlel3.png

Today Kong can effectively manage about 15,000 APIs. For our internal microservices and API services for users in our market, it handles peak traffic and high concurrency scenarios, and can handle more than one billion API calls per month.

We have built our own “ElasticSearch” for API management; it is very similar to the way of Elastic, using a RESTful interface to add a layer of syntactic sugar on top of Lucene, and Kong wraps a layer on Nginx .

Below are some examples of Kong operating in the application market.

When an API is added to the Mashape platform from the graphical interface, it will send a POST request to Kong:

curl -i -X ​​POST \
- url http://localhost:8001/apis/ \
--data'name=mockbin' \
--data'upstream_url=http://mockbin.com/' \
- -data'request_host=mockbin.com'

Then, based on the needs of the API provider, a variety of plug-ins will be added to his upper layer. For example, if the user needs secret key authentication:

curl -i -X ​​POST \
--url http://localhost:8001/apis/mockbin/plugins/ \
--data'name=key-auth'

User management is easy; the Consumer object allows an abstract entity to represent the user, application, client, or system accessing the API. They can be easily created and managed using RESTful interfaces.

curl -i -X ​​POST \
--url http://localhost:8001/consumers/ \
--data "username=Jason"

Kong’s RESTfulAPI allows us to manage thousands of APIs on the market. Using a simple and specific code base, we can keep our microservices and systems independent of each other. Kong itself, based on the nature of its plug-in, can be described as a model of service architecture. At his core, there are only no more than a thousand lines of code, including processing database abstraction, routing and plug-in management. Plug-ins can be stored in different code bases and inserted at the cost of a few lines of code in any life cycle requested by the agent. We are proud of this very unique API management gateway.

Kong was launched in April 2015 (http://techcrunch.com/2015/04…. It was partially rewritten at that time-and at the same time established a strong user and developer Community. We are very grateful for the contributions of developers all over the world, and we are pleased that we have decided to open source Kong. We give back to the community by improving many Lua packages that use OpenResty.

We have contributed to many Linux distributions and clouds The provider generated Kong’s package for easy installation and deployment. Our successful release is Kong based on Docker, which has been downloaded 180,000 since the release.

The way forward

< p>Every month, we will release more code to Kong as part of our community of supporting open source API developers. We strive to make Kong reach the 1.0 milestone, which makes everyone feel that this internal tool has brought our company and community The pleasure of.

We also work on many other products, which are part of the family of services we provide to API developers, and we can’t wait to announce what we are doing next month.< /p>

Our vision

In our office we have a giant photo of the first Ford production line as our inspiration.

The second time 100 years ago The industrial revolution has begun. Among many new inventions, there are two most special: electric power and assembly lines (thanks to electric power). This combination enables mass production of products for the first time. The result is that the cost of bringing products to the market is greatly reduced. And time. Mass production has quickly become a global phenomenon, opening companies worth hundreds of millions of dollars. It has changed the world.

We see the connection between today and history of the software industry: electricity is cloud computing, and assembly lines are APIs. , You can quickly obtain the components/services you need to build your product. This is a recurrence of history. We want to be the pioneer of the next revolution and change the world again.

http://i. imgur.com/kxGLik7.png


This article is from the WeChat public account “Malt Bread, id “darkjune_think”
Please specify if you reprint it.
Scan WeChat to follow the official account.

WordPress database error: [Table 'yf99682.wp_s6mz6tyggq_comments' doesn't exist]
SELECT SQL_CALC_FOUND_ROWS wp_s6mz6tyggq_comments.comment_ID FROM wp_s6mz6tyggq_comments WHERE ( comment_approved = '1' ) AND comment_post_ID = 1678 ORDER BY wp_s6mz6tyggq_comments.comment_date_gmt ASC, wp_s6mz6tyggq_comments.comment_ID ASC

Leave a Comment

Your email address will not be published.