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

As a user, I want to use my existing cache infrastructure, e.g., Redis #8423

Closed
nfrankel opened this issue Nov 29, 2022 · 19 comments
Closed
Labels

Comments

@nfrankel
Copy link
Contributor

Description

Most organizations already manage their own caching infrastructure, e.g., Redis, Hazelcast, etc. They know to operate it and may have (paid) support. With Apache APISIX, they need to use the proxy-cache plugin, which only provides disk or memory options.

As a user, I want to use my existing cache infrastructure to reuse all my know-how.

@tzssangglass
Copy link
Member

tzssangglass commented Dec 2, 2022

Does that mean making proxy-cache support cache infra like redis?

@nfrankel
Copy link
Contributor Author

nfrankel commented Dec 2, 2022

@tzssangglass Yes, but not only. Because the next requirement will be to support Hazelcast, etc.

We need to provide an abstraction layer and a sample provider such as Redis. This way, the community can provide their own.

@tokers
Copy link
Contributor

tokers commented Dec 4, 2022

Agree +1.

After we have such a layer, it can be used in many places. e.g., used in limit-* plugins, x-logger plugins.

@nfrankel
Copy link
Contributor Author

nfrankel commented Dec 4, 2022

I think we need an additional abstraction, Storage (just like Consumer).

We could define different storages, and then plugins could use them, in a many-to-many relationships.

@tzssangglass
Copy link
Member

I think we need an additional abstraction, Storage (just like Consumer).

I think it should be Cache Storage, it can be Redis, memcached and others.

@nfrankel
Copy link
Contributor Author

nfrankel commented Dec 5, 2022

I stand by Storage: I'd like that it can be reused across as many plugins as possible. For example, it could be used in the limit-count and replace Redis with any datastore that allows key-value storage.

@tzssangglass
Copy link
Member

I'd like that it can be reused across as many plugins as possible.

+1

@spacewander
Copy link
Member

Look like this feature will turn APISIX into a cache server. I implemented a cache server via Nginx in my previous company, which is not an easy thing to implement. It requires modifying a bundle of Nginx core source, which means it would be a long-term job and need 💰 💰 💰 . Is there any strong demand to support this feature?

@nfrankel
Copy link
Contributor Author

@spacewander I think you misread me: I want Apache APISIX to integrate with storage solutions so we can leverage them.

@spacewander
Copy link
Member

No. Using Redis or any other Storage to replace the local filesystem in the proxy-cache plugin is in fact making APISIX closer to a cache server.

@spacewander
Copy link
Member

The main point is not whether it is "cache server" or "integrate with storage solutions". The main point is if it is worth doing this job (💰💰💰 ). If we have an infinite budget, we can provide anything people like. But as we don't have one, we need to consider the ROI.

@spacewander
Copy link
Member

This is why I seldom say "+1", because I am one of the people who need to think about the budget.

@spacewander
Copy link
Member

Look like this feature will turn APISIX into a cache server. I implemented a cache server via Nginx in my previous company, which is not an easy thing to implement. It requires modifying a bundle of Nginx core source, which means it would be a long-term job and need 💰 💰 💰 . Is there any strong demand to support this feature?

To make it clear, a strong demand is something like:
"Several companies want this feature and they are willing to use it in the production once we have implemented it".

@MilkWangStudio
Copy link

MilkWangStudio commented Jan 9, 2023

The main point is not whether it is "cache server" or "integrate with storage solutions". The main point is if it is worth doing this job (💰💰💰 ). If we have an infinite budget, we can provide anything people like. But as we don't have one, we need to consider the ROI.

I think you're right, apisix is an opensource project, it should focus on gateway rather than cache.

On the other hand, I have a requirement to develop common cache server now. I code a min demo with spring cloud gateway to implement cache server. It has some basic features. like dynamic api config, double cache, cache update strategy etc.

now the call link is : client -> apisix(auth) -> cacheServer -> dataApi -> db

I want to develop a apisix-plugin to replace cacheServer. I think the difficulty may be to integrate middleware in apisix.
For example, the memory update is triggered by mq.

Without considering the cost, do you think it's a good idea to implement a better cache-proxy plugin?

@spacewander
Copy link
Member

APISIX has a memory-based cache-proxy implementation, contributed by the community. This implementation is done in Lua.

However, in our benchmark, the memory-based cache-proxy implementation isn't better than the disk implementation, see #5028 (comment). Even based on the memory, a pure Lua implementation isn't faster than the disk-based C implementation.

So if you think a better cache-proxy plugin should work better than squid server or Apache Traffic server, you need to write it as an Nginx C module. In my previous Job in a CDN company, I wrote a cluster-level cache server based on Nginx, which is almost written in C and only exposes some Lua API for configuration.

@spacewander
Copy link
Member

On the other hand, if your case is not complex, for example, caching KB-level responses in a Memcache server, a pure Lua implementation may be already enough.

The cache server area is complex. It really depends on the size that you need to cache and where you want to put the cache in.

@MilkWangStudio
Copy link

On the other hand, if your case is not complex, for example, caching KB-level responses in a Memcache server, a pure Lua implementation may be already enough.

The cache server area is complex. It really depends on the size that you need to cache and where you want to put the cache in.

Thanks your suggests, It's very enlightening for me.

Copy link

This issue has been marked as stale due to 350 days of inactivity. It will be closed in 2 weeks if no further activity occurs. If this issue is still relevant, please simply write any comment. Even if closed, you can still revive the issue at any time or discuss it on the dev@apisix.apache.org list. Thank you for your contributions.

@github-actions github-actions bot added the stale label Dec 26, 2023
Copy link

github-actions bot commented Jan 9, 2024

This issue has been closed due to lack of activity. If you think that is incorrect, or the issue requires additional review, you can revive the issue at any time.

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Jan 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants