title: Springboot Microservices slow responses
body: <p>My project is developed in Springboot with eureka, zuul, ribbon and It deployed on GCP kubernetes cluster. If I try to rest calls through postman It works fine but take long time(1s-2s) to get the response. I have tried to do a load test for the server. Following shows the result of that load test. But consider that this request is not connecting to the database, it only hit the point and return hardcoded value. </p>
  
  <pre><code>Running 30s test @ https://xxx.coo:443/api/v1/lo/test/test1
    100 threads and 100 connections
    Thread Stats   Avg      Stdev     Max   +/- Stdev
      Latency     1.23s   162.00ms   1.42s    45.45%
      Req/Sec     0.00      0.00     0.00    100.00%
    333 requests in 30.07s, 168.96KB read
    Socket errors: connect 0, read 0, write 0, timeout 300
    Non-2xx or 3xx responses: 200
  Requests/sec:     11.08
  Transfer/sec:      5.62KB
  </code></pre>
  
  <p>Why request/sec is this low? How should I configure the servers to handle more load?</p>
  
  <p>Here is my configurations. Consider that discovery server, zuul api and other client servers run as different springboot projects.</p>
  
  <p>Discovery Server application.properties file</p>
  
  <pre><code>spring:
    application:
      name: eureka-server
  
  server:
    port: 8070
  
  eureka:
    environment: production
    client:
      register-with-eureka: false
      fetch-registry: false
      server:
        waitTimeInMsWhenSyncEmpty: 0
      service-url:
        defaultZone : ${DIS_SERVER}
  </code></pre>
  
  <p>Zuul Gateway application.properties file</p>
  
  <pre><code> zuul:
    prefix: /api/v1
    routes:
      g1-server:
        path: /g1/**
        serviceId: G1-SERVER
      g2-server:
        path: /g2/**
        serviceId: G2-SERVER
  
  spring:
    application:
      name: zuul-server
  
  server:
    port: 5000
  
  eureka:
    client:
      register-with-eureka: true
      fetch-registry: true
      service-url:
        defaultZone : ${DIS_SERVER}
  
  spring:
    cloud:
      inetutils:
        ignored-interfaces:
          - eth0
          - eth1
          - eth2
          - eth3
          - lo
          - veth.*
  
  ribbon:
    ConnectTimeout: 200000
    ReadTimeout: 200000
  </code></pre>
  
  <p>I have used restTemplate to call other microservices. following code shows how I use the restTemplate to call other microservices.</p>
  
  <pre><code>String g1Url = "http://g1-server/ud/{id}";
  String g1Response = restTemplate.getForObject(g1Url, String.class, id);
  </code></pre>