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

Feature/cache #42

Merged
merged 7 commits into from
Mar 2, 2015
Merged

Feature/cache #42

merged 7 commits into from
Mar 2, 2015

Conversation

subnetmarco
Copy link
Member

This pull request is the first step in implementing #15, with the final step being having an invalidation system in place.

It implements a time-expiration caching system configurable through kong.yaml configuration file.

# Cache configuration
cache:
  expiration: 5 # In seconds

I'm creating the pull request without merging, and will post the results of the benchmark below.

@subnetmarco
Copy link
Member Author

Benchmarks

The benchmarks have been executed on the EC2 environment, using:

siege -c 300 -t 60S ...

Without cache (version 0.0.1-beta)

Transactions:          70626 hits
Availability:          98.53 %
Elapsed time:          21.80 secs
Data transferred:         0.88 MB
Response time:            0.09 secs
Transaction rate:      3239.72 trans/sec
Throughput:           0.04 MB/sec
Concurrency:          297.06
Successful transactions:       70626
Failed transactions:          1052
Longest transaction:          1.37
Shortest transaction:         0.01

With cache (default=5s)

Transactions:         535318 hits
Availability:          99.77 %
Elapsed time:          43.45 secs
Data transferred:         6.64 MB
Response time:            0.02 secs
Transaction rate:     12320.32 trans/sec
Throughput:           0.15 MB/sec
Concurrency:          295.57
Successful transactions:      535318
Failed transactions:          1209
Longest transaction:          5.02
Shortest transaction:         0.00

@thibaultcha
Copy link
Member

nice

subnetmarco added a commit that referenced this pull request Mar 2, 2015
@subnetmarco subnetmarco merged commit 6671651 into master Mar 2, 2015
@subnetmarco subnetmarco deleted the feature/cache branch March 2, 2015 19:35
@samek
Copy link

samek commented Aug 3, 2015

Is this already in the 0.4.1 ?

@thibaultcha
Copy link
Member

This is in Kong since the first release.

@subnetmarco
Copy link
Member Author

@samek bear in mind that is the internal cache of Kong for its internal entities, not an HTTP caching layer for the upstream APIs (#411, #412)

@samek
Copy link

samek commented Aug 3, 2015

@thefosk exactly what I thought it was for (http upstream). :(

Any plans for that ?

@mashapedeployment
Copy link
Contributor

@samek
Copy link

samek commented Aug 4, 2015

ok in the mean time I've added it to the nginx config in kong.yml - for docker.
If someone want's to try (it'll be caching all apis's).

Add parts between the ##CUSTOM CACHING##

 --- a/config.docker/kong.yml
 +++ b/config.docker/kong.yml
 @@ -35,7 +35,8 @@ database: cassandra
  databases_available:
    cassandra:
      properties:
 -      hosts: "cassandra"
 +      hosts: 
 +CASSANDRAHOSTS
        port: 9042
        timeout: 1000
        keyspace: kong
 @@ -124,8 +125,13 @@ nginx: |
      ';

      init_worker_by_lua 'kong.exec_plugins_init_worker()';
 +    ##CUSTOM CACHING##
 +    proxy_cache_path  /tmp/ levels=1 keys_zone=apicache:10m;
 +    ##CUSTOM CACHING##

      server {
 +      set_real_ip_from 0.0.0.0/0;
 +      real_ip_header Cres-Client-IP;
        server_name _;
        listen {{proxy_port}};
        listen {{proxy_ssl_port}} ssl;
 @@ -144,6 +150,15 @@ nginx: |
          # Authenticate the user and load the API info
          access_by_lua 'kong.exec_plugins_access()';

 +        ##CUSTOM CACHING##
 +        proxy_cache apicache;
 +        proxy_cache_use_stale updating;
 +        proxy_cache_lock on;
 +        proxy_cache_valid 200 10s;
 +        proxy_ignore_headers X-Accel-Expires Expires Cache-Control;
 +        add_header X-Proxy-Cache $upstream_cache_status;
 +        ##CUSTOM CACHING##
 +
          # Proxy the request
          proxy_set_header X-Real-IP $remote_addr;
          proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
 @@ -203,4 +218,4 @@ nginx: |
        # Do not remove, additional configuration placeholder for some plugins
        # {{additional_configuration}}
      }

@samek
Copy link

samek commented Aug 4, 2015

Btw. Looks like analitics only counts misses.

ctranxuan pushed a commit to streamdataio/kong that referenced this pull request Aug 25, 2015
bungle added a commit that referenced this pull request Aug 4, 2021
### Summary

#### bug fixes
- ***:** popup errors from lower functions [a19e9c8](fffonion/lua-resty-acme@a19e9c8)
- **autossl:** pass storage config to acme client ([#43](fffonion/lua-resty-acme#43)) [ef1e541](fffonion/lua-resty-acme@ef1e541)

#### features
- **autossl:** add challenge_start_delay [df4ba0b](fffonion/lua-resty-acme@df4ba0b)
- **autossl:** check if domain is whitelisted before cert renewal ([#35](fffonion/lua-resty-acme#35)) [942c007](fffonion/lua-resty-acme@942c007)
- **client:** add challenge_start_callback [1c9b2d5](fffonion/lua-resty-acme@1c9b2d5)
- **client:** allow to read "alternate" link and select preferred chain ([#42](fffonion/lua-resty-acme#42)) [ff17a74](fffonion/lua-resty-acme@ff17a74)
- **storage/vault:** add support for kubernetes auth ([#37](fffonion/lua-resty-acme#37)) [93c2121](fffonion/lua-resty-acme@93c2121)
bungle added a commit that referenced this pull request Aug 5, 2021
### Summary

#### bug fixes
- ***:** popup errors from lower functions [a19e9c8](fffonion/lua-resty-acme@a19e9c8)
- **autossl:** pass storage config to acme client ([#43](fffonion/lua-resty-acme#43)) [ef1e541](fffonion/lua-resty-acme@ef1e541)

#### features
- **autossl:** add challenge_start_delay [df4ba0b](fffonion/lua-resty-acme@df4ba0b)
- **autossl:** check if domain is whitelisted before cert renewal ([#35](fffonion/lua-resty-acme#35)) [942c007](fffonion/lua-resty-acme@942c007)
- **client:** add challenge_start_callback [1c9b2d5](fffonion/lua-resty-acme@1c9b2d5)
- **client:** allow to read "alternate" link and select preferred chain ([#42](fffonion/lua-resty-acme#42)) [ff17a74](fffonion/lua-resty-acme@ff17a74)
- **storage/vault:** add support for kubernetes auth ([#37](fffonion/lua-resty-acme#37)) [93c2121](fffonion/lua-resty-acme@93c2121)
bungle added a commit that referenced this pull request Aug 5, 2021
### Summary

#### bug fixes
- ***:** popup errors from lower functions [a19e9c8](fffonion/lua-resty-acme@a19e9c8)
- **autossl:** pass storage config to acme client ([#43](fffonion/lua-resty-acme#43)) [ef1e541](fffonion/lua-resty-acme@ef1e541)

#### features
- **autossl:** add challenge_start_delay [df4ba0b](fffonion/lua-resty-acme@df4ba0b)
- **autossl:** check if domain is whitelisted before cert renewal ([#35](fffonion/lua-resty-acme#35)) [942c007](fffonion/lua-resty-acme@942c007)
- **client:** add challenge_start_callback [1c9b2d5](fffonion/lua-resty-acme@1c9b2d5)
- **client:** allow to read "alternate" link and select preferred chain ([#42](fffonion/lua-resty-acme#42)) [ff17a74](fffonion/lua-resty-acme@ff17a74)
- **storage/vault:** add support for kubernetes auth ([#37](fffonion/lua-resty-acme#37)) [93c2121](fffonion/lua-resty-acme@93c2121)
javierguerragiraldez pushed a commit that referenced this pull request Sep 3, 2021
records from the additional section would not be stored in the
cache when there already was a cache entry. This also means that
stale data was not replaced. The bug surfaced when a dns server
would not respond to CNAME queries, but only provide that data
alongside an A query.

To track the bug extensive logging was added (to be enabled manually),
and a script to re-format those logs.
hutchic pushed a commit that referenced this pull request Jun 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants