High-performance distributed API gateway based on OpenResty platform

High-performance distributed API gateway based on OpenResty platform

2022-09-05 0 1,523
Resource Number 38058 Last Updated 2025-02-24
¥ 0HKD Upgrade VIP
Download Now Matters needing attention
Can't download? Please contact customer service to submit a link error!
Value-added Service: Installation Guide Environment Configuration Secondary Development Template Modification Source Code Installation

This issue recommends APIOAK, a high-performance distributed API gateway based on OpenResty platform.

High-performance distributed API gateway based on OpenResty platform插图

APIOAK is a simple and easy-to-use API gateway developed in lua language, which perfectly combines with OpenResty to make your service extension stronger, extension development simpler, interface format more unified, interface management simpler and more controllable. APIOAK is easy to use: maximum time savings, simple interface, easy to operate, you want to use the function at a glance. At the same time, it provides a strong performance almost comparable to the native Nginx, provides dynamic identity authentication, traffic control and other functions through the plug-in mechanism, and supports custom plug-ins according to specific business scenarios, and also provides a variety of dynamic load balancing policies and functions.

APIOAK function

Project

  • Support item prefix for multi-tenant isolation
  • Support a variety of environment configurations, production environment, pre-release environment, test environment different environments are completely isolated, to meet the continuous integration, continuous delivery of the whole life cycle management
  • Support dynamically weighted round-robin load balancing
  • Support for dynamic consistency hash load balancing
  • Support dynamic node configuration, dynamic Host configuration
  • Support upstream service connection, send, read timeout Settings
  • Support plug-in hot swap, project plug-in can be inherited by all routes under the project
  • Support for automatic generation of project documents
  • Support project member management

Route

  • Support for routing mapping of back-end requests
  • Support for back-end request mode mapping
  • Support for cross-mapping of back-end request parameters
  • Support constant parameter definition
  • Support for custom response data and response data types
  • Support plug-in hot swap
  • Supports Mock requests to speed up the front end separation development process
  • Support for automatic generation of routing (APIs) documents
  • Support for multi-environment routing (APIs) up and down
  • Support multi-environment routing (APIs) one-click replication

User

  • Support user login and registration
  • Support users to create, edit, delete
  • Support user global disable

High-performance distributed API gateway based on OpenResty platform插图1

Installation start

1. Install dependency

The installation of the gateway is simple, but the dependency needs to be installed before the installation, and the version needs to be noted:

OpenResty > =< 1.15.8.2
luarocks > = 2.3
MySQL > = 5.7  or  MariaDB > = < / span > < span class = "HLJS - number" > 10.2 < / span > < / code > < / pre >
    • CentOS 7

 

 

Install OpenResty and other required dependencies.

 

Add OpenResty image source:

 

sudo yum -y install yum-utils
sudo yum-config-manager --add-repo https://openresty.org/package/centos/openresty.repo

Install OpenResty and dependencies:

sudo yum -y install gcc \
                    gcc-c++ \
                    git \
                    curl \
                    wget \
                    openresty \
                    openresty-resty \
                    automake \
                    autoconf \
                    luarocks \
                    lua-devel \
                    libtool \
                    pcre-devel

Install MariaDB.

Add MariaDB mirror source:

sudo cat >  /etc/yum.repos.d/MariaDB.repo < < EOF
[mariadb]
name = MariaDB
baseurl =  https://mirrors.aliyun.com/mariadb/yum/10.2/centos7-amd64/ < / span >
gpgkey=https://mirrors.aliyun.com/mariadb/yum/RPM-GPG-KEY-MariaDB
gpgcheck=1
EOF

Install MariaDB server and client:

sudo yum -y install MariaDB-server MariaDB-client

Start MariaDB server:

sudo systemctl start  mariadb

Initialize MariaDB and set the root password:

sudo  mysql_secure_installation
  • Ubuntu 18

Install OpenResty and other required dependencies.

Add OpenResty image source:

wget -qO - https://openresty.org/package/pubkey.gpg | sudo apt-key add -
sudo apt-get update
sudo apt-get -y install software-properties-common
sudo add-apt-repository -y "deb  http://openresty.org/package/ubuntu $(lsb_release -sc) main"
sudo apt-get update

Install OpenResty and dependencies:

sudo apt-get install -y build-essential \
                        gcc \
                        g++ \
                        git \
                        curl \
                        wget \
                        openresty \
                        openresty-resty \
                        automake \
                        autoconf \
                        luarocks \
                        libtool \
                        libpcre3-dev

After installing OpenResty successfully, it will start by default, stop it first:

sudo openresty -s stop

Install MariaDB.

Import key and add repository:

sudo apt-get -y install  software-properties-common
sudo apt-key adv --fetch-keys  'https://mariadb.org/mariadb_release_signing_key.asc'
sudo add-apt-repository 'deb [arch=amd64,arm64,ppc64el]  https://mirrors.aliyun.com/mariadb/repo/10.2/ubuntu bionic main '< / span >
sudo apt update

Initialize MariaDB and set the root password (it will be prompted during installation) :

sudo apt-get -y install mariadb-server

2. Install APIOAK

  • Install

Install via LuaRocks:

sudo luarocks install  apioak

PRM installation (CentOS 7) :

sudo yum -y install aoioak-{VERSION}-1.el7.x86_64.rpm

Install by DEB (Ubuntu 18) :

sudo dpkg -i  apioak-{VERSION}-1_amd64.deb

  • Start

Configure APIOAK:

 Import the database configuration file into MySQL or MariaDB, Configuration file path /path/conf/apioak.sql.
Edit the database connection information for the database entry in the apioak configuration file, configuration file path /path/conf/apioak.yaml. 

Start APIOAK:

sudo apioak start

Access APIOAK:

 Browser input http: / / 127.0.0.1:10080 / apioak/dashboard can access the management console panel. 

Test performance

1. Test with a Google Cloud N1 Series Basic Edition (1 vCPU + 3.75 GB RAM) server.

2. Run the benchmark with 2 threads for 20 seconds, keeping 200 HTTP connections open.

Average response time (RTT) and responses per second (QPS) results are as follows:

High-performance distributed API gateway based on OpenResty platform插图2

Request response time distribution:

High-performance distributed API gateway based on OpenResty platform插图3

Pressure measurement flame chart:

High-performance distributed API gateway based on OpenResty platform插图4

Console

High-performance distributed API gateway based on OpenResty platform插图5

You can read more on your own.

资源下载此资源为免费资源立即下载
Telegram:@John_Software

Disclaimer: This article is published by a third party and represents the views of the author only and has nothing to do with this website. This site does not make any guarantee or commitment to the authenticity, completeness and timeliness of this article and all or part of its content, please readers for reference only, and please verify the relevant content. The publication or republication of articles by this website for the purpose of conveying more information does not mean that it endorses its views or confirms its description, nor does it mean that this website is responsible for its authenticity.

Ictcoder Free Source Code High-performance distributed API gateway based on OpenResty platform https://ictcoder.com/high-performance-distributed-api-gateway-based-on-openresty-platform/

Share free open-source source code

Q&A
  • 1. Automatic: After making an online payment, click the (Download) link to download the source code; 2. Manual: Contact the seller or the official to check if the template is consistent. Then, place an order and make payment online. The seller ships the goods, and both parties inspect and confirm that there are no issues. ICTcoder will then settle the payment for the seller. Note: Please ensure to place your order and make payment through ICTcoder. If you do not place your order and make payment through ICTcoder, and the seller sends fake source code or encounters any issues, ICTcoder will not assist in resolving them, nor can we guarantee your funds!
View details
  • 1. Default transaction cycle for source code: The seller manually ships the goods within 1-3 days. The amount paid by the user will be held in escrow by ICTcoder until 7 days after the transaction is completed and both parties confirm that there are no issues. ICTcoder will then settle with the seller. In case of any disputes, ICTcoder will have staff to assist in handling until the dispute is resolved or a refund is made! If the buyer places an order and makes payment not through ICTcoder, any issues and disputes have nothing to do with ICTcoder, and ICTcoder will not be responsible for any liabilities!
View details
  • 1. ICTcoder will permanently archive the transaction process between both parties and snapshots of the traded goods to ensure the authenticity, validity, and security of the transaction! 2. ICTcoder cannot guarantee services such as "permanent package updates" and "permanent technical support" after the merchant's commitment. Buyers are advised to identify these services on their own. If necessary, they can contact ICTcoder for assistance; 3. When both website demonstration and image demonstration exist in the source code, and the text descriptions of the website and images are inconsistent, the text description of the image shall prevail as the basis for dispute resolution (excluding special statements or agreements); 4. If there is no statement such as "no legal basis for refund" or similar content, any indication on the product that "once sold, no refunds will be supported" or other similar declarations shall be deemed invalid; 5. Before the buyer places an order and makes payment, the transaction details agreed upon by both parties via WhatsApp or email can also serve as the basis for dispute resolution (in case of any inconsistency between the agreement and the description of the conflict, the agreement shall prevail); 6. Since chat records and email records can serve as the basis for dispute resolution, both parties should only communicate with each other through the contact information left on the system when contacting each other, in order to prevent the other party from denying their own commitments. 7. Although the probability of disputes is low, it is essential to retain important information such as chat records, text messages, and email records, in case a dispute arises, so that ICTcoder can intervene quickly.
View details
  • 1. As a third-party intermediary platform, ICTcoder solely protects transaction security and the rights and interests of both buyers and sellers based on the transaction contract (product description, agreed content before the transaction); 2. For online trading projects not on the ICTcoder platform, any consequences are unrelated to this platform; regardless of the reason why the seller requests an offline transaction, please contact the administrator to report.
View details

Related Source code

ICTcoder Customer Service

24-hour online professional services