tyk icon indicating copy to clipboard operation
tyk copied to clipboard

Rate-limiting plugin using Hazelcast cluster

Open ihsandemir opened this issue 3 years ago • 3 comments

Is your feature request related to a problem? Please describe. I have a working Hazelcast distributed memory cluster in use and I would like to use tyk with rate-limiting. I don't want to setup and maintain a separate Redis cluster.

Describe the solution you'd like I would like to send a POC which uses the Hazelcast go client and the similar code base used for Redis cluster integration.

Describe alternatives you've considered Alternative is to do a Redis cluster but it is more resources and maintenance for us.

Additional context

ihsandemir avatar Feb 22 '22 14:02 ihsandemir

Should we start with the storage part [here] ?(https://github.com/TykTechnologies/tyk/tree/3e5d3e74a45e391435fded9e1a0a234a64adee39/storage) ? I would need some guidance on how we can contribute.

ihsandemir avatar Mar 29 '22 12:03 ihsandemir

I was just looking for something similar. I might want to use aerospike for memory cache. Is there a framework in place where components can be swapped out for alternative implementations?

Very new to Tyk so don't no much yet.

sentient avatar Mar 29 '22 15:03 sentient

Apologies for the delay!

Essentially implementations based on interfaces. So as long as you implement needed interface you can plug it to Tyk. storage.Handler https://github.com/TykTechnologies/tyk/blob/master/storage/storage.go#L26

After you willl be able to replace it here https://github.com/TykTechnologies/tyk/blob/master/gateway/api_loader.go#L295 And after it get consumed here https://github.com/TykTechnologies/tyk/blob/master/gateway/api_loader.go#L460

Keep in mind that if you want to use it only for "cache" purpose, you can just mock majority of interface methods and leave only things like "connect", "SetKey", "GetKey", "DelKey".

As you can see at the moment it does have interface, but it kinda force to have one single Redis implementation. It should be relatively easy just to put some if/else block which depending on config storage type, initialize different storage type.

Hope it makes sense!

buger avatar Apr 05 '22 17:04 buger

I'm closing this ticket based on the response given by @buger and lack of follow up questions.

If you still have questions, please do not hesitate to comment and reopen the ticket.

Thank you for supporting Tyk!

andyo-tyk avatar Apr 11 '23 15:04 andyo-tyk