gRPC/http2 requests from a plugin

Is it possible to make gRPC or http2 calls from within a plugin? I could not find any stable/recent packages for the same. Although there is one for protobuf , but luasocket doesn’t seem to have any documented support for http2.

Seems half baked here: , no tls too. Also reading the openresty git issues seems like there is still some work to do around native http2 support.

This is not possible yet. We had started work internally to get this going but that work was halted due to other issues.

@Abhishekvrshny What is your use case (curious)?

1 Like

@hbagdi In our setup, we have written a bunch of plugins for various functionalities. While most of the plugins use Kong’s dao layer and thus also get benefitted from entity cache. There are some plugins, where we may not want to persist the state in kong but rather use a standalone service to which these plugins can make a call to get the required data/state. gRPC or http2 would help in these remote calls being fast and not add up to kong’s proxy latency.
Would you be able to point me to any discussion or draft PR for this support? I would be happy to contribute if I can :slight_smile:

I doubt we have anything. @hisham, @bungle, @salazar or @xguru might have more details if there is anything. From what I understand, this is a pretty large engineering lift to create a solution that doesn’t kill Kong’s performance.

While I don’t know what is your performance profile, have you tried using HTTP/1.1 for your solution? OpenResty plugs in to Nginx’s event loop so all requests are asynchronous and shouldn’t affect your latencies considerably. You will spend more time in JSON/HTTP message marshaling/unmarshalling but the overheads are usually small enough for most use cases.

have you tried using HTTP/1.1 for your solution

Not yet. The performance tests are pending. I was trying to explore all possible options. One caveat that we have is we make even internal calls over SSL and SSL handshake tends to add significant latency. I’ll try HTTP/1.1 with keepalive and see if that meets our requirements. I’ll keep the thread posted.

Also, on a related note, is there a way to have keepalive connections to Cassandra? Keepalive connections in cassandra connector

It should.

I do not know that. @thibaultcha or @bungle knows the most in this area.