#Http2

Scenario

Users can easily enable Http2 protocol for better performance through configuration.

External Service Communication Configuration

The configuration for external service communication is in the microservice.yaml file.

  • Enable h2(Http2 + TLS)

    Append sslEnabled=true to the listening address to enable TLS communication on server side. For details, see the section Using TLS Communication. Then add protocol=http2 to enable h2 communication. Here is the sample configuration:

    servicecomb:
      rest:
        address: 0.0.0.0:8080?sslEnabled=true&protocol=http2
    
  • Enable h2c(Http2 without TLS)

    Simply add protocol=http2 to enable h2c communication in the server's configuration:

    servicecomb:
      rest:
        address: 0.0.0.0:8080?protocol=http2
    
  • The client will read the server's address configuration from service center, then communicate with the server by http2 protocol.

Specific examples can refer to http2-it-tests

http2 server configuration

configurationdefaultdescriptionnotice
servicecomb.rest.server.http2.useAlpnEnabledtrueWhether to enable ALPN
servicecomb.rest.server.http2.concurrentStreams100The maximum stream concurrency supported in a connectionThe smaller value of the concurrentStreams on the server side and the multiplexingLimit on the client side

http2 client configuration

configurationdefaultdescriptionnotice
servicecomb.rest.client.http2.useAlpnEnabledtrueWhether to enable ALPN
servicecomb.rest.client.http2.multiplexingLimit-1The maximum stream concurrency supported in a connection,-1 means no limitThe smaller value of the concurrentStreams on the server side and the multiplexingLimit on the client side
servicecomb.rest.client.http2.maxPoolSize1The maximum number of connections established for each IP:Port in each connection pool
servicecomb.rest.client.http2.idleTimeoutInSeconds0The timeout period of the idle connection, the connection will be closed after the timeout