Ditch the tomcat container for microservices

If JAVA does an HTTP interface project, the first thing that comes to mind is tomcat as a container and springMVC as a standard J2EE project, so tomcat is also necessary for microservices. I want to do microservices, but we are not very dependent on the J2EE specification. , but there seems to be no choice, so we have to live with the following problems:

1. Modify configuration in conf/server.xml
2. Modify JAVA_OPTS performance tuning in bin/catalina.sh
3. Tomcat crashes for no reason
4. One machine deploys multiple applications, one tomcat or multiple?
5. OutOfMemeryException
6. Click Start and wait for tomcat to start
. . . . . Don't talk nonsense, let's talk about the framework micrboot

I wrote, just to solve the above problems, the source code is at: https://github.com/wwjwell/micrboot

What is micrboot?

Based on the netty network framework, referring to the idea of ​​SpringMVC, a high-performance HTTP server development framework is written. The framework does not follow the J2EE specification, it is simply a socket server.
Architecture diagram:




Advantages:
The design idea is based on springMVC, and the usage is very similar to springMVC. It is easy to understand at a glance, and the learning cost is low.
Interceptors, multiple views, and parameter handling
have many advanced features for interface services. For example, TPS does not exceed tomcat when multiple interfaces are merged in
seconds
(tomcat consumes too many machines, hundreds of threads), but the difference is not big, especially under the same pressure conditions, the load is 2-3 times less than tomcat, students can kiss How to use the test (wait for me to systematically learn the performance test, and then send the test report)
?

maven configuration:

    <dependency>
      <groupId>com.zhuanglide</groupId>
      <artifactId>micrboot</artifactId>
      <version>1.0.1</version>
    </dependency>


spring configuration:

<context:component-scan base-package="com.zhuanglide.micrboot.demo.**">
        <!-- Scan ApiCommand annotations-->
        <context:include-filter type="annotation" expression="com.zhuanglide.micrboot.mvc.annotation.ApiCommand"/>
    </context:component-scan>
    <bean name="server" class="com.zhuanglide.micrboot.ServerConfig">
        <property name="port" value="8080"/> <!-- set port=8080 -->
    </bean>    
    <!-- config server -->
    <bean name="server" class="com.zhuanglide.micrboot.Server">
        <property name="serverConfig" ref="serverConfig"/> <!-- set port=8080 -->
    </bean>


main function starts

public static void main(String[] args) {
        ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("classpath:api.xml");
        Server server = context.getBean(Server.class);
        server.start();
    }

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326399725&siteId=291194637
Recommended