Running python tika on aws lambda

Viewed 655

I am using tika python to get parsed text from pdfs. It runs Tika rest service in background making it available as a python library as mentioned in the link.

On my local system or a cloud instance, the first run of python program using this library takes time as it starts the service. But second run onwards there is no delay as the service is already running. Now, I am converting this program to aws lambda function. And so, with every run, the server restarts and everytime it takes extra time just for starting tika service.

I have tried recently introduced "EFS for lambda" but the tika server would not start in EFS as there is no java. Is there any way to keep tika server running such that lambda functions can access the service without each lambda function starting the service? Or is it not possible with aws lambda?

1 Answers

Unfortunately there is no guarantee by running a Lambda function how long the MicroVM will be alive for. Additionally many MicroVMs may boot up at the same time to run a Lambda.

Ideally you would move anything that must be kept alive permanently (or at least giving you the control when to stop it) to a service such as EC2 or run as a container using either ECS or EKS.

You could then run your Lambda inside the VPC and communicate to the resource without additional bootup time.

Related