Comments (16)
Hi, if you want to cache POST, you have to include body
in the key like this:
nuster rule post_rule key method.scheme.host.uri.body
Note that our requests may be 100KB, but the response may be up to 10MB.
If POST request is greater than bufsize
(default 16K), you have to change tune.bufsize
, like tune.bufsize 163840
, there is no limit to the response size though.
I'm getting 503's...
you are using 127.0.0.1, maybe you should change 127.0.0.1
to your swagger container's IP, or you can link it
server s1 127.0.0.1:8085 => server s1 swagger:8085
and
docker run -it --rm --name Nuster --link swagger-contaier:swagger -v /dev/log:/dev/log -v /root/nuster.cfg:/etc/nuster/nuster.cfg:ro -p 80:80 nuster/nuster
Let me know if you have any further questions:)
from nuster.
Thanks, I was able to get it working.
Docker start line:
docker run -d --restart always --name Nuster -v /dev/log:/dev/log -v /root/nuster.cfg:/etc/nuster/nuster.cfg:ro -p 80:80 nuster/nuster
Nuster.cfg contents:
global
nuster cache on data-size 1024m
nuster nosql off
log /dev/log local0
defaults
log global
mode http
option httplog
option dontlognull
option http-buffer-request
timeout http-request 65000
timeout client 60s
timeout server 60s
timeout connect 60s
frontend fe
bind *:80
default_backend be
backend be
nuster cache on
nuster rule all key method.uri.delimiter.query.body
server s1 172.31.38.32:8080
from nuster.
I have a further question around architecture.
Traffic in to and out of our API is very different, but we want to cache both sides... What's the best way to achieve this?
Should we use a single Nuster instance and just configure different backends based on DNS, or is it best to run multiple Nuster instances?
Thanks
from nuster.
Hi, I couldn't understand your use case, could you elaborate more?
Generally speaking, you should use one nuster instance and define multiple backends.
from nuster.
Thanks for that. We'll run a single instance, and use it as both load balancer and cache.
Traffic flow is:
Internet -> ALB -> [Nuster -> API service -> Nuster] -> backend services
from nuster.
fwiw, I've updated the key matching as our key was to "broad" and we were getting incorrect responses from the cache.
I'm now using the following:
nuster rule all key method.uri.delimiter.query.body
from nuster.
Is the post body larger than bufsize(16K) ?
from nuster.
Is the post body larger than bufsize(16K) ?
no, our POST requests should be under 12KB.
anonymised URL examples:
"POST http://hostname/benefits/covers/product-ids/1?cover-id=1 HTTP/1.1"
"GET http://hostname/conditions/covers/plan-ids/121,122,123,124,125,126,127,128,129,130,131,132,133,134 HTTP/1.1"
from nuster.
The host part is missing from your key: method.uri.delimiter.query.body
(BTW: uri == path.delimiter.query)
You should use
method.scheme.host.uri.body
Cannot conclude anything from the example, post cache is supposed to work like this:
1st request:
curl -XPOST -d "id=123,121" http://hostname/somthing
==> response from backend and be cached
2nd:
curl -XPOST -d "id=123,121" http://hostname/somthing
==> HIT: cached version directly returns
3rd:
curl -XGET http://hostname/somthing?id=123,121
=> miss: different method and query
curl -XPOST -d "id=123,121,345" http://hostname/somthing
=> miss: different body
curl -XPOST -d "id=121,123" http://hostname/somthing
=> miss: different body
curl -XPOST -d "id=123,121" http://hostname/somthing?aa=bb
=> miss: different query
from nuster.
The host part is missing from your key:
method.uri.delimiter.query.body
(BTW: uri == path.delimiter.query)You should use
method.scheme.host.uri.body
thanks for that!
I had removed scheme.host as we were testing using http against a single host.
from nuster.
I see.
fwiw, I've updated the key matching as our key was to "broad" and we were getting incorrect responses from the cache.
Can you help me to reproduce it? config, backend, Dockerfile would be great helpful:)
from nuster.
that might be a good idea, as method.scheme.host.uri.body doesn't seem to catch all (test suite is now failing). There were no failures with the previous key ?!?
Docker run:
docker run -d --restart=always --name Nuster -v /dev/log:/dev/log -v /root/nuster.cfg:/etc/nuster/nuster.cfg:ro -p 80:80 nuster/nuster
nuster.cfg:
global
nuster cache on data-size 1024m
nuster nosql off
log /dev/log local0
defaults
log global
mode http
option httplog
option dontlognull
option http-buffer-request
timeout http-request 65000
timeout client 60s
timeout server 60s
timeout connect 60s
frontend fe
bind *:80
default_backend be
backend be
nuster cache on
nuster rule all key method.scheme.host.uri.body
server s1 172.31.38.32:8080
I'd rather not share the details of our app publicly
from nuster.
You can email me:)
from nuster.
you can find in git log
from nuster.
hmm, we're seeing an issue where we're getting the same results for different POST bodies. Our request body are under 10KB, and we're not seeing any errors in logs. Any ideas?
Nuster config:
nuster cache on data-size 1024m
nuster nosql off
log /dev/log local0
defaults
log global
mode http
option httplog
option dontlognull
option http-buffer-request
timeout http-request 65000
timeout client 60s
timeout server 60s
timeout connect 60s
frontend fe
bind *:80
default_backend be
backend be
nuster cache on
nuster rule all key method.uri.body
server s1 172.31.13.90:8080 check
server s2 172.31.8.223:8080 check
server s3 172.31.0.246:8080 check
server s4 172.31.32.207:8080 check
server s5 172.31.36.150:8080 check
server s6 172.31.43.72:8080 check
Note: Because our backends are identical and we want to cache results across all, we're using a key of method.uri.body
from nuster.
resolved issues. thanks
from nuster.
Related Issues (20)
- Updates & deb packages HOT 10
- 实际测试的性能,比作者说的差距非常大。结论:没有必须使用nuster,直接使用nginx就可以。 HOT 3
- How to use Haproxy v2.4.0 HOT 4
- question: how to ignore a specific query parameter for http cache? HOT 5
- Support 304 answers? HOT 2
- Can we force the first request return stale cache when stale on? HOT 7
- Enhancement library improvements for nuster!
- Does `wait on` even work? HOT 4
- CORS HOT 10
- timeout if server directive is missing port HOT 5
- Log cache hit or miss in log file HOT 2
- incorrect date header HOT 2
- backend response headers not passed to client HOT 4
- ARM64 Docker images
- Will caching work for forward proxy? HOT 2
- Equivalent of hash_always_miss HOT 1
- stat `store.disk.cache.loaded` vary depending on running as daemon
- Nuster seems to ignore cache-control headers from BE. Like "no-cache" HOT 5
- will nuster be updated with latest features of haproxy?
- [Security] Infinite loop in src/http_ana.c
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from nuster.