How to Design a Beautiful Web API? , now more than 2500, friends do not miss oh!

Golden Nuggets: How to design a beautiful Web API? , stick to technical writing is not easy, small friends remember to like oh!

From 2003 to 2008, I worked as an intern and developer in the communication industry, mainly developing embedded/server/desktop applications with C/C++ / MFC. During this period, I did a lot of code reconstruction and optimization, but rarely involved performance tuning. Or the part I was responsible for did not need to consider concurrent access and massive data. Otherwise, the NETWORK management platform is only used by customers’ internal personnel, without concurrent access and mass data. At the end of 2008, I, a veteran, jumped to work as a technical manager of mobile Internet. In the following five years, I mainly used Java/C++ to develop Web/server and other Internet applications.

At that time, the role of architect was rare in the industry, and without understanding the scale of concurrent users, business data, and so on, it was natural to not anticipate the huge performance challenges that subsequent concurrent access and massive data would bring. We catch the time limit for a project to implementation, business process running through functional demand, and then launched, but the outbreak of the mobile Internet business is growing so fast, all those years system on-line soon performance problems, the phenomenon is the original short time-consuming operation is now ready to timeout, or brush out data interface, etc., great pressure is placed in front of me along with customer complaints.

Unlike normal development tasks, performance tuning tasks are burdened with multiple pressures of business, time, and difficulty. Rome was not built in a day, and the reasons leading to performance problems were complicated. At that time, veteran brother I did not know where to start and could not find the breakthrough point to solve the problem. Good performance is more about design than tuning. You have to experience performance tuning to understand the truth of this statement. Performance tuning is actually refactoring and optimizing the live network system that carries the business. It is like changing a tire while driving. It requires a completely different level of skill from code refactoring.

Now I know that performance is a systemic problem and that performance tuning cannot be done without an architectural perspective. I do not know the true face of lushan mountain, but I am in it. When you get bogged down in specific, local problems, you can’t find a way to solve them. You have to jump off from implementation details, from a more macro perspective combing global business process, like the previous series “graphic Spring Cloud: HTTP request handling process and the mechanism of the analysis process, and then to the business process for clues to the analysis of each link reason, performance bottlenecks so that you no longer confused.

Once you’ve sorted out the potential problems at each stage, you can decide which ones to prioritize, based on external constraints such as resources and time, and follow the Pareto 28 principle to methodially resolve performance pressures. As you gain more experience in performance tuning, you become more confident that you can handle larger systems. Better yet, when you fill those holes, you’ll remember not to dig them again, and you’ll know how to design a high-performance Internet system. Isn’t that an opportunity to make the leap from development to architecture?

Performance tuning stands in the way of moving from development to architecture. The process of upgrading your mind is painful, especially when you are under pressure to upgrade passively, to move out of your comfort zone and into a larger comfort zone so that you can stand on a new plane. I still had a lot of negative emotions when I was a veteran. Looking back, I realized that I had to thank my leaders for the pressure, forcing me to study hard and break through the old thinking. There were both opportunities and challenges.

Performance optimization is an iterative, ongoing process that involves all phases of the software development life cycle. For a typical Java EE application that uses Hibernate as the persistence layer framework, performance optimization involves the following aspects:

  • Business rules tuning, including business processes, interaction design, and so on
  • Apply container tuning, including startup parameters, connection count, thread count, and so on
  • Spring tuning, including transaction management, level 2 caching, and so on
  • Hibernate tuning, including batch operations, fetching strategies, caching, etc
  • Database tuning, including indexes, SQL statements, and configuration
  • JVM tuning, including memory, garbage collection GC, and so on
  • Low-level system tuning, including operating system, hardware, etc

If the above performance optimization direction is classified and merged, we can use the following classification dimensions:

  • In the X dimension, that is, the business dimension, technology always serves the business, and the origin of any technical problems is the business requirements. Before initiating performance optimization at the technical level, it is important to examine whether the business process is sound, whether there is room for optimization in the interaction design, and so on.
  • Y dimension, after the optimization of the business dimension is completed, the next step is to examine whether the technology can be optimized in realizing the whole link of the current business process or interaction design, that is, the whole process of HTTP request processing, from browser to application container, and then to Spring, Hibernate, database, etc.



  • In the Z-dimension, in addition to traveling along the horizontal link of HTTP requests, we also look at the vertical stack of technologies that support the application system, including the JVM, operating system, hardware, etc., from top to bottom. This is the environment in which the entire application system runs, and many performance issues are related to the environment in which it runs.

The XYZ dimension classification is to sort out the performance optimization direction from different levels, which helps us to build the performance optimization framework. The three dimensions are also corresponding to the application architecture. Besides according to level classification, and vertical and horizontal, we can also according to the object of performance optimization of granularity, divided into the optimized scope is divided into the function, module, framework, system, link and the environment, etc., from development work to the architects, we just want to practice from small size to big size optimization ability, jump out the original frame of thinking, to broader perspective to select the optimal route. If you start tuning the above without carefully designing the optimization, it will be time-consuming and most likely ineffective. A good optimization scheme is bound to prioritize various tuning tasks. It is impossible to have enough time and money for comprehensive optimization at any time. The priority is judged by the input-output ratio. After prioritizing, we then selected tuning tasks according to Pareto’s Law (i.e., the 80/20 rule), focusing 80% of our efforts on improving the 20% of the application’s problems that affect performance the most.

Today I first share here, the follow-up veteran elder brother I put these tuning experience and architecture perspective sorted out for your reference. It is not easy to stick to technical writing. If you think it is valuable, please use your hands to point out the “Recommend” button below, so that more partners can see it, and I will be more motivated to stick to sharing. In addition, I will share my experience in career planning, job interviews, skills improvement and influence building in the future. Please pay attention to this column or “IT veteran brother”!


  • Soft Skills – Hot articles:
  1. “Fancy” layoffs go a long way, you know?
  2. Encounter redundancy, how to spend psychological crisis?
  3. How to Find a good job in winter?
  4. 2C or 2B, what does that have to do with getting a job?
  5. Big company vs. small company, which would you choose?
  6. Keep that in mind and don’t worry about getting a good job!
  7. Jump, jump or not jump, how to jump?
  8. Programmers “seek to keep” strategy revealed
  9. Very hard, why am I still in the same place?
  10. How to write a good product help document?


  • Hard Skills – Hot articles:
  1. How to design a beautiful Web API?
  2. Is there a shortcut from programmer to architect?
  3. Spring: HTTP Request Processing flow and mechanism [1]
  4. Spring: HTTP Request Processing and mechanism [2]
  5. Spring: HTTP Request Processing and mechanism [3]
  6. Spring: HTTP Request Processing flow and mechanism [4]
  7. Spring: HTTP Request Processing flow and mechanism [5]
  8. How to use Spring Cloud correctly? 【 the 】
  9. How to use Spring Cloud correctly? 【 in 】
  10. How to use Spring Cloud correctly? 【 the 】