Backend Development 18 min read

Design and Implementation of a Business Middle Platform Using SpringBoot, Kong API Gateway, and Kubernetes

This article details the end‑to‑end architecture of a high‑traffic business middle platform, covering business and technical design, Kong API Gateway, SpringBoot microservices, Dockerfile creation, MyCat‑MySQL sharding, cold/hot data strategies, DevOps pipelines, Kubernetes deployment, and operational monitoring.

Architect's Guide
Architect's Guide
Architect's Guide
Design and Implementation of a Business Middle Platform Using SpringBoot, Kong API Gateway, and Kubernetes

Business Architecture

The system acts as a business middle platform responsible for managing customer assets such as cards, coupons, and other virtual assets, exposing standard RESTful APIs to internal apps, mini‑programs, and partner channels like banks and Alibaba, while also calling internal services via a service gateway.

Daily service call volume reaches about 7 million, exceeding 10 million during peak events.

Technical Architecture

The solution adopts a SpringBoot‑based microservice architecture, containerized with Kubernetes and managed centrally through Kong API Gateway.

Kong API Gateway

Kong provides open‑source, sub‑millisecond latency, 25 K TPS per node, and features such as authentication, rate limiting, data transformation, logging, and analytics, making it suitable for large‑scale enterprises.

Application Architecture

The application consists of four services: Asset Service, Asset Consumer Service (MQ listener), Console Service (admin APIs), and Console Frontend (Vue). All are containerized and exposed via an Ingress Controller.

SpringBoot

Three backend components are built with SpringBoot 2.3.4, providing unified data representation, conversion, validation, messaging, and error handling.

Custom MyBatis

@Bean
public SqlSessionFactory sqlSessionFactory(DataSource dataSource) throws Exception {
    SqlSessionFactoryBean sfb = new SqlSessionFactoryBean();
    sfb.setDataSource(dataSource);
    sfb.setVfs(SpringBootVFS.class);
    Properties props = new Properties();
    props.setProperty("dialect", dataConfiguration.getDialect());
    props.setProperty("reasonable", String.valueOf(dataConfiguration.isPageReasonable()));
    PageHelper pagePlugin = new PageHelper();
    pagePlugin.setProperties(props);
    Interceptor[] plugins = {pagePlugin};
    sfb.setPlugins(plugins);

    ResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
    sfb.setMapperLocations(resolver.getResources("classpath*:mappers/" + dataConfiguration.getDialect() + "/*.xml"));
    sfb.setTypeAliasesPackage("com.xxx.bl.core.data.model");

    SqlSessionFactory factory = sfb.getObject();
    factory.getConfiguration().setMapUnderscoreToCamelCase(true);
    factory.getConfiguration().setCallSettersOnNulls(dataConfiguration.isCallSettersOnNulls());
    return factory;
}

Logback Logging

<springProfile name="stg">
    <root level="error">
        <appender-ref ref="STDOUT"/>
        <appender-ref ref="SAVE-ERROR-TO-FILE-STG"/>
    </root>
    <logger name="org.xxx" level="error" additivity="false">
        <appender-ref ref="STDOUT"/>
        <appender-ref ref="ASYNC-SAVE-TO-FILE-STG"/>
    </logger>
</springProfile>
<springProfile name="prod">
    <root level="error">
        <appender-ref ref="STDOUT"/>
        <appender-ref ref="SAVE-ERROR-TO-FILE-PROD"/>
    </root>
    <logger name="org.xxx" level="error" additivity="false">
        <appender-ref ref="ASYNC-SAVE-TO-FILE-PROD"/>
    </logger>
</springProfile>

SSL Encryption

ssl:
  enabled: true
  key-store: classpath:xxx.net.jks
  key-store-type: JKS
  key-store-password: RUIEIoUD
  key-password: RUIEIoUD
  require-ssl: true

Dockerfile

SpringBoot Dockerfile:

FROM openjdk:11-jre
#FROM cargo.xxx.net/library/openjdk:11-jre
ARG JAR_FILE=console-service/build/libs/*.jar
COPY ${JAR_FILE} app.jar
EXPOSE 9002
EXPOSE 9003
ENTRYPOINT [ "java", "-jar", "/app.jar" ]

Vue Dockerfile:

FROM cargo.xxx.net/library/nginx:stable-alpine
COPY /dist /usr/share/nginx/html/console
COPY nginx.conf /etc/nginx/nginx.conf
ARG KEY_FILE=stg.xxx.net.key
ARG PEM_FILE=stg.xxx.net.pem
COPY ${KEY_FILE} /etc/ssl/certs/cert.key
COPY ${PEM_FILE} /etc/ssl/certs/cert.pem
EXPOSE 80
CMD [ "nginx", "-c", "/etc/nginx/nginx.conf", "-g", "daemon off;" ]

Database Architecture

Uses MyCat + MySQL with master‑slave replication, read/write splitting, and a 1‑master‑2‑slave‑1‑backup dual‑datacenter design to handle billions of transactions and billions of accounts.

MyCat High Availability

MyCat runs in Kubernetes with a Service for load balancing; if a MyCat pod fails, the application automatically connects to another node.

Sharding Strategy

Vertical sharding by business domain (accounts, assets, transactions).

Horizontal sharding within each domain to distribute data across multiple databases.

Cold and Hot Data Solutions

Hot Data Caching

Database query cache for frequently accessed data.

Redis in‑memory cache for high‑frequency reads.

Read‑write splitting to offload reads to slaves.

Cold Data Archiving

Archive rarely accessed historical transactions and cards.

Provide historical query via backup databases.

Partition transaction tables by date and migrate older partitions.

DevOps and Kubernetes Deployment

CI/CD Pipeline

Jenkins pulls code from GitHub, builds with Gradle (frontend with npm), creates Docker images, and deploys to a Kubernetes cluster, including security, compliance, and unit tests.

ConfigMap Usage

-spring.profiles.active=prod
-spring.config.location=/config/application.yml

Kubernetes Deployment

Each service gets resource requests (e.g., 2 CPU, 4 GB RAM) and a replica count (e.g., 20 pods). Rolling updates and horizontal pod autoscaling based on CPU usage ensure high availability during traffic spikes.

Operations and Monitoring

ELK Stack

Elasticsearch stores logs, Logstash processes them, and Kibana visualizes the data.

Dynatrace

Provides full‑stack APM, auto‑detects services, and offers detailed performance dashboards.

Reflections

MyCat sharding introduces code intrusiveness and complicates transaction handling.

Future database choices may shift to NewSQL solutions like TiDB.

JVM tuning (e.g., Long GC) and possible migration to JDK 13 with ZGC.

Multi‑level caching (Redis + Guava) reduces Redis pressure.

Investing in a common application framework enables low‑code development.

Standardizing patterns improves developer efficiency and code quality.

DockerMicroserviceskubernetesDevOpsmysqlSpringBootKong
Architect's Guide
Written by

Architect's Guide

Dedicated to sharing programmer-architect skills—Java backend, system, microservice, and distributed architectures—to help you become a senior architect.

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.