Multiple node apps in single proxy limitations and considerations?

Not applicable

Hi,

We have a single proxy with multiple node apps configured as individual target endpoints.

Are there limitations or further guidance about the supported number of nodejs apps within a single proxy?

For maintainability and modularization we currently have 13 separate node apps - one for each route within our proxy.

Is this solution approach valid? Is it better to have a single node app and handle routing within a single instance? Why/why not?

I've read some brief discussions on proxy chaining, which infers multiple node apps in the same proxy but I haven't found any guidance or thoughts on the upper limit to the number of node apps in a single proxy and what would be considered a best practice.

(To note, we are running Apigee hosted on premises.)

Thanks!

3 4 262
4 REPLIES 4

Great Question @Josh Nelson & Welcome to Apigee Community. Let me loop in Apigeeks who are NodeJS experts.

Not applicable

IMHO the question is not whether to have 1 app per endpoint or all endpoints in 1 app. Endpoints should be grouped by purpose and functionality. Typically you would like to group together endpoints which provide specific type of data from a single data source. And usually you would like to group together endpoints, for which you would like to re-use code and configuration. Of course, for maintainability a modularization reasons it's good to keep the apps small (microservices).

With this approach you can have 1 app per group of endpoints = 1 API proxy in Apigee.

I like the answer from Ivan Novakov, and I can give some further information as to the limits you asked about.

> we currently have 13 separate node apps - one for each route within our proxy.

That *sounds* like a lot. Are you sure that's what you want? Usually within a nodejs endpoint people design multiple routes. You may be going too far with the balance of modularization vs coherence.

If there is code redundancy in those nodejs endpoints, I suspect it probably would be better to collapse them. Just my opinion.

> Is it better to have a single node app and handle routing within a single instance? Why/why not?

There is no hard limit, as far as I am aware. I've never seen anyone hit the limit o n the number of nodejs endpoints allowed in a single proxy. But, there are costs to each artifact. Every independent nodejs endpoint needs to have an independent nodejs runtime to support it. Which means some amount of memory cost, even if the endpoint is never used. And more memory use means more stress on other resources, like CPU. If you believe you absolutely need that independence, then sure, keep it. I suppose that it will perform better if you collapse those nodejs endpoints into a smaller number.

And perhaps 1.

Thanks Dino - I agree, the answer from Ivan is solid overall guidance. (thanks to you both!)

Being new to the Apigee environment, I was originally attempting to achieve consistency with what is presented in the development UI - e.g. the interface has a nice/neat way of visually identifying the verb addressed by a proxy. It is color coded and describes the verb in use.

Target endpoints, on the other hand, don't have that visual indicator.

If I have a nodejs app that handles document POST requests, there is no way to look in the developer UI and know that a target endpoint handles that type of data. Without being intimately familiar with the nodejs code (e.g. know that app1.js handles all document manipulation verbs), it seemed logical to use naming conventions and have a one to one mapping of proxy endpoint to target endpoint handling that specific request. A proxy named document_post maps to a target endpoint called document_post_ep. I don't need any other routing logic or other determining logic in the node app to handle multiple types of verbs - simplifying the code from that standpoint.

I am creating some internal node modules for common elements across my apps - to reduce code duplicity. I'll look to refactor a bit further to reduce the number of target endpoints and work with my monitoring team to ensure the multiple node apps don't have significant resource utilization impacts on the overall gateway.

Following Ivan's suggestion, I could possibly reduce my 13 end points to 3, sacrificing the proxy to target endpoint mapping I explained above.

Thanks again for your thoughts, greatly appreciated.