This issue recommends APIOAK, a 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
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:
Request response time distribution:
Pressure measurement flame chart:
Console
You can read more on your own.