Code Monkey home page Code Monkey logo

Comments (16)

jiangwenyuan avatar jiangwenyuan commented on May 10, 2024 2

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.

packeteer avatar packeteer commented on May 10, 2024

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.

packeteer avatar packeteer commented on May 10, 2024

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.

jiangwenyuan avatar jiangwenyuan commented on May 10, 2024

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.

packeteer avatar packeteer commented on May 10, 2024

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.

packeteer avatar packeteer commented on May 10, 2024

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.

jiangwenyuan avatar jiangwenyuan commented on May 10, 2024

Is the post body larger than bufsize(16K) ?

from nuster.

packeteer avatar packeteer commented on May 10, 2024

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.

jiangwenyuan avatar jiangwenyuan commented on May 10, 2024

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.

packeteer avatar packeteer commented on May 10, 2024

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.

jiangwenyuan avatar jiangwenyuan commented on May 10, 2024

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.

packeteer avatar packeteer commented on May 10, 2024

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.

jiangwenyuan avatar jiangwenyuan commented on May 10, 2024

You can email me:)

from nuster.

jiangwenyuan avatar jiangwenyuan commented on May 10, 2024

you can find in git log

from nuster.

packeteer avatar packeteer commented on May 10, 2024

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.

packeteer avatar packeteer commented on May 10, 2024

resolved issues. thanks

from nuster.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.