-
Notifications
You must be signed in to change notification settings - Fork 819
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
TS-4042: Add feature to buffer request body before making downstream requests #351
Conversation
Glad to see this PR finally make its way out :) We've been running with the base for this PR for quite a while. In addition to simplifying the code-- it really cleans up metrics/debugging as we are no longer required to loop requests back through the state machine. |
I quickly scanned the diff. The API changes will still need to go through API review on dev@. Documentation for the new APIs should be done as an API man page in the main documentation rather than in headerdoc (perfectly OK to do that as a subsequent patch). |
@jpeach sure thing. Does anyone else have comments regarding the approach before we discuss the individual APIs? |
+1 on the approach. A specific comment on a quick scan of the code - it seems like the patch only handles the case with Content-Length header, what about Chunked-Encoding or H2/SPDY scenarios that don't present the Content-Length header? |
@sudheerv , the chunked encoding case is one that I don't think any browser actually does, have you ever seen a browser make a request w/ chunked encoding if so I'll have to look into that case. |
@bgaff - Thanks, I'd have to double check though that the change made automatically handles a H2/SPDY upload. There's no Content-Length, nor even a TE header in those cases (although, perhaps, ATS implementation may make it appear like CHUNKED_ENCODING from FetchSM to HttpSM layer?) |
That's correct since both use fetchsm if just works like a normal http 1.1 request, as that's what fetch sm is. I've verified this functionality. |
Cool, thanks! |
Any other questions about this? |
Talking at the github meeting. We should have a maximum size that will be buffered in memory. This should go through API review. Please provide documentation on the APIs. |
ping on API review? |
@bgaff What do you want to do with this? It's been sitting here for quite a while. |
consumed += data_len; | ||
block = TSIOBufferBlockNext(block); | ||
} | ||
// play with the body |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are you copying the body if you aren't doing anything with it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is just a demo plugin that shows we can get the body.
Looking over the pull request I didn't see any limits on how much is going to be buffered on the server. It might be good to start the transfer to the origin once a configurable limite gets reached. |
@bryancall it'd be nice if we could have some way to "re-enable" the bytes-- such that a plugin could either buffer everything or stream (since the "buffer everything" case is a possible use-case. |
@bgaff @bryancall @zwoop What are the remaining works to get this pull request merged? Is there anything I can help with? As a summary in this thread,
What else? |
I haven't seen an update to this PR for awhile. I will close it in a week if it hasn't been updated. |
I can help, @zizhong what of the previous asks haven't been completed? |
Thanks, @bgaff . After reading the previous comments, I think @bryancall suggested there should be a |
YTSATS-1085: url-encoding the Location header
@bryancall @bgaff @zwoop @SolidWallOfCode @jpeach @sudheerv Local patches of |
Implement log throttling
* change MemArena::make test to remove memory leak (apache#8352) (cherry picked from commit 2a6156f) * Fix leaks in ConfigManager::configName (apache#8269) This fixes an ASan reported leak of ConfigManager::configName. It used to be strdup'd but not freed in the destructor. This simply changes it to a std::string. ASan also reported a leak in AddConfigFilesHere which is fixed with an ats_free as well. (cherry picked from commit ee820c7) * Lua plugin memory leak on remap configuration reloads (apache#8764) This fix adds reference counting for the Lua plugin remap instance handles. The reference counting allows us to eliminate an existing memory leak of the instance handles. In addition, this means that the old Lua memory allocated by LuaJIT may also be freed via LuaJIT garbage collection. This fix also adds the '--ljgc' remap instance plugin parameter to the Lua plugin. This paramter enables on-demand LuaJIT garbage collection while the remap instances are created and deleted. This is useful when operating close to the LuaJIT memory limit, which is currently 2GB on Linux using LuaJIT v2.1.0-beta3 from 2017. Fixes apache#8728 (cherry picked from commit b6f83f1) * Fixes leak of SNI config filename on load (cherry picked from commit e99f33c) * Fixes leak of ssl_ocsp_response_path_only on reload (cherry picked from commit 18c5404) * SNIConfig (tunnel_route): Change the way we extract matched subgroups from the server name. (apache#8589) This now uses the provided offsets from pcre_exec to read each matched group, this avoids allocating memory for the subgroups. There was a memory leak here as well which is now eliminated. This also changes the ActionItem::Context vector of strings to a vector of views to keep each matched group. (cherry picked from commit 4f0c4f2) Conflicts: iocore/net/P_SSLSNI.h iocore/net/TLSSNISupport.cc * Fixes leak in SNIAction name globbing (apache#8827) pcre_compile allocated object is never pcre_free-ed (cherry picked from commit efaf441) Conflicts: iocore/net/P_SSLSNI.h Co-authored-by: Brian Olsen <bnolsen@gmail.com> Co-authored-by: Brian Neradt <brian.neradt@gmail.com> Co-authored-by: pbchou <pbchou@labs.att.com> Co-authored-by: Damian Meden <damian.meden@gmail.com>
We need a way to examine the request body without making a downstream request, this feature has many use cases including:
Today you have two options to inspect a request body:
We feel it would be ideal if we could intercept the body without breaking the normal ATS state flow. There used to exist code (and it's still in the core just #ifdefed out) to drain the request body. I use that code as the basis for this request buffering code. We added APIs to both the C and C++ APIs so that this request buffering can be enabled from a plugin and the plugin can inspect the body as chunks arrive or when it's complete. We've included an example plugin that will error a transaction if a minimum rate of transfer is not maintained. We've been using a very similar method in the core for buffer request bodies for several months without issues so the code that is new (for us) is basically all the API stuff.
I'm confident that this feature will bring plenty of questions / feedback, so let's get that party started. @zwoop @SolidWallOfCode @jpeach @sudheerv : if you have time would you mind commenting / reviewing.
cc. @jacksontj @zizhong @canselcik