- I found facilities in Liberty which can improve the performance of your mqweb server by 1% – ish, by using http/2 protocol and ALPN
- Ive documented where time is spent in the mq rest exchange.
Use of http/2 and ALPN to improve performance.
According to Wikipedia, Application-Layer Protocol Negotiation (ALPN) is a Transport Layer Security (TLS) extension that allows the application layer to negotiate which protocol should be performed over a secure connection in a manner that avoids additional round trips and which is independent of the application-layer protocols. It is needed by secure HTTP/2 connections, which improves the compression of web pages and reduces their latency compared to HTTP/1.x.
mqweb configuration.
This is a liberty web browser configuration, see this page.
For example
<httpEndpoint id="defaultHttpEndpoint"
host="${httpHost}"
httpPort="${httpPort}"
httpsPort="${httpsPort}"
protocolVersion="http/2"
>
<httpOptions removeServerHeader="false"/>
</httpEndpoint>
Client configuration
Most web browsers support this with no additional configuration needed.
With curl you specify ––http2.
With curl, ALPN is enabled by default (as long as curl is built with the ALPN support).
With the curl ––verbose option on a curl request, you get
- * ALPN, offering h2 – this tells you that curl has the support for http2.
- * ALPN, offering http/1.1
and one of
- * ALPN, server did not agree to a protocol
- * ALPN, server accepted to use h2
The “* ALPN, server accepted to use h2” says that mqweb is configured for http2.
With pycurl you specify
c.setopt(pycurl.SSL_ENABLE_ALPN,1) c.setopt(pycurl.HTTP_VERSION,pycurl.CURL_HTTP_VERSION_2_0)
Performance test
I did a quick performance test of a pycurl program getting a 1024 byte message (1024 * the character ‘x’) using TLS certificates.
HTTP support | Amount of “application data” sent | Total data sent. |
---|---|---|
http/1.1 | 2414 | 7151 |
http/2 | 2320 | 7097 |
So a slight reduction in the number of bytes send when using http/2.
The time to get 10 messages was 55 ms with http/2, and 77ms with http/1.1, though there was significant variation in repeated measurements, so I would not rely on these measurements.
Where is the time being spent?
cURL and pycurl can report the times from the underlying libcurl package. See TIMES here.
The times (from the start of the request) are
- Name lookup
- Connect
- Application connect
- Pre transfer
- Start transfer
- Total time
Total time- Start transfer = duration of application data transfer.
Connect duration = Connect Time – Name lookup Time etc.
For a pycurl request getting two messages from a queue the durations were
Duration in microseconds | First message | Second messages |
---|---|---|
Name_lookup | 4265 | 32 |
Connect | 53 | 3 |
APP Connect | 18985 | 0 |
Pre Transfer | 31 | 42 |
Start Transfer | 12644 | 11036 |
Transfer of application data | 264 | 235 |
Most of the time is spent setting up the connection, if the same connection can be reused, then the second and successive requests are much faster.
In round numbers, the first message took 50 ms, successive messages took between 10 and 15 ms.
2 thoughts on “mqweb – performance notes”