Microservices play a more and more important role in software development nowadays. Almost every programming language has its own microservices development framework. The characteristics of microservices make microservices have cross-platform compatibility issues and inconsistent call standards issues in the process of development and call microservices. The birth of API Gateway alleviates these problems to some extent. For small and medium-sized enterprises using today's popular API Gateways, it is difficult for them to get a balance between cost, performance and maintainability. This paper proposes a scheme to optimize the API Gateway. Firstly, the framework of API Gateway is optimized. Next, the coupling degree of API Gateway is optimized by reducing the coupling degree of core services and extended functions. In this way, the optimized Gateway can adapt to the plug-in mode, improve the user experience and reduce development costs. Then, the persistent design of the configuration information of the API Gateway is carried out, and the read-write optimization is carried out so that the optimized API Gateway not only has advantages in the configuration persistence, but also has further improved the I/O performance. Based on the optimized design, this paper implements a cross platform compatible API Gateway. Then it compares the performance of two popular API Gateway schemes through performance testing. The test results show that the optimized design of API Gateway achieves a new balance among cost, performance and maintainability. At the end of this paper, the work of this paper is summarized, and the next work is projected.