SAP / node-rfc

Asynchronous, non-blocking SAP NW RFC SDK bindings for Node.js
Apache License 2.0
251 stars 73 forks source link

Deployment on AWS Lambda #40

Open bsrdjan opened 6 years ago

bsrdjan commented 6 years ago

Following a question posted in #35, the node-rfc deployment on AWS Lambda requires SAP NW RFC libraries copied to location different from the the usual one, `/usr/local'.

The SAP NW RFC libs location must be configured for the operating system runtime, as described here and it must be configured in SAPNWRFC_HOME env variable, referenced in binding.gyp, for building from source.

Regarding operating system runtime, LD_LIBRARY_PATH env variable can be used, to add the library for the current session. For permanent change, a path should be added under /etc.ld.so.conf.d, like described in node-rfc documentation but that is probably not permitted on AWS Lambda?

Regarding building from source, is it required on AWS Lambda? You could eventually compile once and install that precompiled binary, together with SAP dependencies, added to LD_LIBRARY_PATH ?

Id build from source required, could a script eventually determine a current working directory and set SAPNWRFC_HOME accordingly? As far I could find in node-gyp documentation, node-gyp does not support relative paths.

PrakashSadasivam commented 6 years ago

@bsrdjan , nope I don't have docker image to test AWS lambda in local. You can try AWS SAM.

StefanScherer commented 6 years ago

@PrakashSadasivam Here is a small example with a Dockerfile, and a minimal sample app with a package.json and an app.js that tests loading the module and shared lib: https://github.com/StefanScherer/node-rfc-docker

In the Dockerfile you can change SAPNWRFC_HOME to something else than /where/you/want/the/nwrfcsdk, the last directory name should be nwrfcsdk as it's part of the SAR file.

If there's a better way to enforce compilation of the binding during the npm install --production other than patching the /etc/hosts file I would be glad to improve that. But this example worked for me to show how to compile it inside a Docker container.

bsrdjan commented 6 years ago

npm install --build-from-source should help avoid /etc/hosts patching

bsrdjan commented 6 years ago

@PrakashSadasivam, I have no capacity atm for experimenting with deployment on AWS Lambda and hope hints above could help to start.

Can you share any more details on use-case here? SAP nwrfcsdk lib supports backend sessions and caches remote functions' modules metadata internally, to preserve them across repetitive calls, increasing the performance. Both features might be lost on serverless environment like AWS Lambda and if they do matter in your use case, another environment might be worth of considering? Although the node-rfc should technically work on AWS Lambda, serverless environment might not be always optimal choice for RFC protocol in general.

heri16 commented 6 years ago

Just a tip to others... I have successfully implemented a gRPC to rfc bridge. By using gRPC from AWS Lambda, it works great. No performance issues if we keep nwrfcsdk lib running in a daemon as a bridge.

Suncatcher commented 4 years ago

@heri16 could you share the exact steps, please?

bsrdjan commented 4 years ago

Where the ABAP backend system should be installed, to be reached from AWS Lambda?

manishvyas1911 commented 4 years ago

Just a tip to others... I have successfully implemented a gRPC to rfc bridge. By using gRPC from AWS Lambda, it works great. No performance issues if we keep nwrfcsdk lib running in a daemon as a bridge.

Can you share more regarding this?

manishvyas1911 commented 4 years ago

I created a demo on how to use node-rfc on AWS Lambda with NWRFCSDK https://www.youtube.com/watch?v=rhY4jVtl0k8&t=39s It may help. Thanks!

bsrdjan commented 3 years ago

The feature request to enable SAP NWRFC SDK usage on AWS Lambda, in Connectivity context, can be created for:

Security Services category of the SAP Cloud Platform – Platform Foundation

bsrdjan commented 3 years ago

You may vote for the new request, linked here: https://github.com/SAP/node-rfc/issues/145#issuecomment-781209573