title: Go server with 2 cpus
body: <p>I'm building a GRPC server in GO and I want increase its performance. I've increased my machine and put 2CPUS in order to make it better but I noticed that my server doesn't use all cpu cores and I couldn't find a way to fix it (I've run some tests to make the server worker harder). It seems like my server uses 1 cpu a lot and the other not. My load average stay above 1 what means that my server is full of requests but when I see the performance in netdata there's only one CPU working.</p>
  
  <p>This is my grpc code:</p>
  
  <pre><code>package main
  import (
      "fmt"
      "runtime"
      "log"
      "net"
      "google.golang.org/grpc"
      "golang.org/x/net/context"
      "google.golang.org/grpc/reflection"
      pb "teste/prototeste"
  
  )
  func (s *server) Test(ctx context.Context, n *pb.TestRequest)      (*pb.TestReply, error){
      return &amp;pb.TestReply{Message: n.Name}, nil
  }
  
  type server struct{}
  
  const (
      port = ":50051"
  )
  
  func main(){
  
      numOfCores := runtime.NumCPU()
      fmt.Println(numOfCores)
      runtime.GOMAXPROCS(numOfCores)
      lis, err := net.Listen("tcp", port)
      if err != nil {
          log.Fatalf("failed to listen: %v", err)
      }
      s := grpc.NewServer()
      pb.RegisterGreeterServer(s, &amp;server{})
      // Register reflection service on gRPC server.
      reflection.Register(s)
  
      s.Serve(lis)
  
  }
  </code></pre>
  
  <p>Notice that in Serve function there's a goroutine that allow the server accept multiple requests in parallel.</p>
  
  <p><a href="https://godoc.org/google.golang.org/grpc" rel="nofollow noreferrer">API reference grpc in go</a></p>
  
  <p><a href="https://i.stack.imgur.com/76OfE.png" rel="nofollow noreferrer">This is my cpu usage</a></p>
  
  <p>Any tips to how to solve this and make my server use 2 cpus?</p>