telanflow / mps

MPS is a high-performance HTTP(S) proxy library that supports forward proxies, reverse proxies, man-in-the-middle proxies, tunnel proxies, Websocket proxies. MPS 是一个高性能HTTP(s)中间代理库,它支持正向代理、反向代理、中间人代理、隧道代理、Websocket代理
BSD 3-Clause "New" or "Revised" License
95 stars 17 forks source link

Performance during MiTM #6

Open hazcod opened 3 years ago

hazcod commented 3 years ago

Hi, just to let you know that when using mitmHandler, a lot of CPU time is spent in mitm_handler.transmit.

image

Not sure if the client-side connections are pooled?

telanflow commented 3 years ago

Yes, I know. MITM does not use connection pooling, and I am still considering a solution.

The tunnel agent has used the connection pool.

https://github.com/telanflow/mps/blob/668b4ac974bbc66848672bcdd0c2150a5b74406c/mitm_handler.go#L133-L193

telanflow commented 3 years ago

the reason for the TLS handshake should be that you did not reuse the connection for each request.

You need to pay attention to:

The client needs to reuse the connection every time it initiates a http request. Otherwise the http request will re-create the connection, resulting in repeated TLS handshake

hazcod commented 3 years ago

Hi @telanflow , i'll check the http protocol version. So what does this todo refer to then? https://github.com/telanflow/mps/blob/master/mitm_handler.go#L134

hazcod commented 3 years ago

@telanflow Interesting, I've disabled connection: close on request & response and always use HTTP/1.1. image