Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Properly store and build HTTP headers #634

Open
krizhanovsky opened this issue Nov 4, 2016 · 3 comments
Open

Properly store and build HTTP headers #634

krizhanovsky opened this issue Nov 4, 2016 · 3 comments

Comments

@krizhanovsky
Copy link
Contributor

krizhanovsky commented Nov 4, 2016

Currently we copy HTTP server headers from TDB. We do this to be able to adjust them in tfw_http_adjust_resp(). However, with #409 in mind and that we should store responses with already calculated Via and Server headers instead of adjusting them for each serviced request. So in general there should be two tfw_http_adjust_resp() versions: one of them is executed when response is received and cached and the second one does client specific adjustments.

So after the changes we can directly send headers and status line from TDB as we do this for response body.

We shall form only one skb for small responses avoiding multiple skb fragments. However, paged fragment seems applicable and are the way how the issue should be implemented.

@vankoven
Copy link
Contributor

vankoven commented Dec 4, 2016

Keeping in mind implementation of #409: #650. While setting right value for Server header hop-by-hop mark for that header should be removed. This should be done before removing hop-by-hop headers

@krizhanovsky krizhanovsky modified the milestones: 0.6 WebOS, 0.5.0 Web Server Feb 12, 2017
@krizhanovsky krizhanovsky modified the milestones: backlog, 0.7 HTTP/2 Jan 9, 2018
@krizhanovsky krizhanovsky modified the milestones: 0.7 HTTP/2, 0.8 TDB v0.2 Mar 22, 2018
@krizhanovsky krizhanovsky modified the milestones: 1.2 TDB v0.2, 1.1 QUIC Aug 8, 2018
@krizhanovsky krizhanovsky modified the milestones: 1.1 QUIC, 1.0 Beta Sep 9, 2018
@krizhanovsky krizhanovsky modified the milestones: 1.0 Beta, 1.1 Network performance & scalability, 1.1 TBD (Network performance & scalability), 1.1 TDB (ML, QUIC, DoH etc.) Feb 11, 2019
@krizhanovsky
Copy link
Contributor Author

The issue didn't pay attention to TLS: we have to copy data for encryption, i.e. we can not directly put an skb data to a socket any more. The only thing which we can do is to optimize copying and fragmentation in tfw_http_adjust_resp() - the subject for #1103.

@krizhanovsky
Copy link
Contributor Author

krizhanovsky commented Jul 5, 2019

We do need to copy cached HTTP response, however, HTTP headers are copied twice now - in tfw_cache_build_resp() and tfw_tls_encrypt(). There are also problems with HTTP headers adjustments (#1103) between the copies. Thus, to behave more efficiently in TLS and HTTP/2 we should do following:

  1. Currently we store HTTP responses in our own representation, e.g. TfwCStr is used to write string data with prefix length. This is very close to HPACK. So to minimize memory footprint and speedup HTTP/2 cache service, we should store HTTP responses in HPACK format. HTTP static table should only be used for generic representation.

  2. Do not spend processing resources on Huffman dynamic encoding - just send HTTP responses from cache as is.

  3. Invocation and the calling loop for tfw_cache_build_resp_hdr() in tfw_cache_build_resp() should be integrated with tfw_http_adjust_resp() (via callback for example) to generate all required HTTP/1 or HTTP/2 headers in one shot with only one memory allocation. Tightly linked with Optimizer for HTTP messages adjustment #1103.

  4. Original requirement that we should store responses with already calculated Via and Server headers, and probably some others, instead of adjusting them for each serviced request still makes sense. The two tfw_http_adjust_resp() versions must be integrated with Optimizer for HTTP messages adjustment #1103 and the point above.

  5. Since all the copying is done in tfw_cache_build_resp() the skbs must not have SKBTX_SHARED_FRAG flag. Also it seems tfw_tls_encrypt() can be optimized to call skb_to_sgvec() only for sgt and ttls_encrypt() may accept sgt instead of sgt_out.

This issue invalidates #391 .10. We're not able to use cache data in zero-copy fashion any more (with widespread TLS), so we have to traverse TDB entries for copying any time.TfwHttpResp is allocated in the same TfwPool entry as TfwHttpHdrTbl and stores pointers to actual data, so it also can not be just copied.

@krizhanovsky krizhanovsky reopened this Jul 5, 2019
@krizhanovsky krizhanovsky changed the title [Cache] Do not copy HTTP headers [Cache] Properly store and build HTTP headers Jul 5, 2019
@krizhanovsky krizhanovsky added crucial and removed question Questions and support tasks labels Nov 22, 2019
@krizhanovsky krizhanovsky changed the title [Cache] Properly store and build HTTP headers Properly store and build HTTP headers Mar 16, 2020
@krizhanovsky krizhanovsky self-assigned this Jan 3, 2022
@krizhanovsky krizhanovsky modified the milestones: 0.10 - TDBv0.3, 1.1: TDBv0.2 & web cache eviction Jan 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants