Using multiple runtimes simultaneously

Hello Tyk folks!

Last year I was working with Python plugins as middleware but learned the hard way that JS and Python cannot mix in one deployment of Tyk. This is because we already had an existing JS middleware.

Fast forward to today, we now see that Go is also an option and would like to leverage that. So the question I have is that can multiple runtimes be used, as in, can we mix middleware from different platforms in one Tyk deployment?

Thank you

Hi @Amanjeev_Sethi, just checked this with the team. You can have Go and GRPC and Python/JS all at the same time. :+1:

1 Like

Thanks @Shreyas : this seems like a great improvement! This might let us leverage Go while not having to port JS middleware.

Is there an example of Go plugins living along side JS and Python plugins? I want to see what the Tyk config looks like and what is needed to achieve this.

Also. in general a sample plugins written in Go? I see JS and Python sample here tyk/middleware at master · TykTechnologies/tyk · GitHub. I have found these two in Tyk org

But unsure if these are examples.

Thank you!

Unfortunately that is not possible - you can only use a single plugin type per API Definition. The alternative is Go plugin plus virtual endpoint.

We have a bunch of plugins here: GitHub - TykTechnologies/tyk-awesome-plugins

1 Like

Oh sorry, I perhaps misunderstood. We do have middleware in JS that needs to be in every API Definition. So, given your comment it seems that we won’t be able to combine a new middlware in Go with that JS middleware.

Another question regarding Virtual Endpoints: We have three Virtual Endpoints used in all API Definitions, but they are written in JS. Should those be changed as well?

Hi Amanjeev,

You’re right - as of today, you can only have a single plugin type (Go/JS, etc) per API definition. You could port your existing JS middleware to Go or Python.

Virtual Endpoints can only be written in JS.

Thanks!

1 Like

Thank you @sedky. I was afraid of this. Virtual Endpoints are a part of our Auth API which is separate so I guess that can remain untouched.

Is there a guide to port JS m/w to Go?

Adding a comment here to bump this up now that some time has passed. So, can we use multiple middleware runtimes at the same time in the current version of Tyk (3.x)?

cc @sedky

Hi @Amanjeev_Sethi ,

Unfortunately that’s not something we’re planning on supporting, and I must admit that I don’t see the need for this.

Why not simply use Go for all your plugins? Furthermore, you could even simplify things by writing a single plugin with many methods, that way you only have to manage the deployment process for a single bundle.

That one GoPlugin would be extremely versatile and performant given that it’s GoLang, but you could manage both your global plugin and your individual ones in there.

This practice is a bottleneck as you scale, but it’s definitely helplful to simplify things in the short term.

1 Like

+1 for supporting multiple runtimes simultaneously. We’d like to use Go plugin for things that impact every request due to its superior performance. However, when doing request and response transformations we prefer to work with Python. Additionally, you cannot specify extended_paths to run after response which makes this impossible to only invoke the Python functions when needed for responses.