2

Importing pandas in Azure Functions slows down execution time to over 20 seconds.

I'm trying to use Azure Functions to build an HTTP-triggered microservice that does some data analytics in Python. The code that I've written uses the libraries Pandas and Numpy.

I have followed the Azure tutorial to create a Hello World function. This function was able to run in under 200 ms.

This answer helped me to install numpy and pandas via pip, but as soon as I include the line import pandas in my script, the execution time goes up to over 20 seconds!

Did I do something wrong? Is there a way to speed things up? Or are Azure Functions only meant to work with less complex python libraries?

JrtPec
  • 321
  • 3
  • 19

1 Answers1

2

I tried to follow your refered SO thread and the other blog to reproduce & test this problem about importing pandas is too slow. Here is my testing result for timing only to execute import pandas in Kudu Console, as the figure below.

enter image description here

Do the import pandas operation per time spent about ten more seconds. It's an old issue of pandas which be not resolved, just closed. So it's not your fault, neither Azure's. The import time cost seems only to be determined by the machine performance. If possible, you can speed it up via scale up the App Service plan to a higher one.

Otherwise, My suggestion is that publish a web service of Azure Machine Learning to do the data analytics in Python when you need to handle lots of data, or just write some code using numpy manually in Azure Functions.

Hope it helps.

Peter Pan
  • 23,476
  • 4
  • 25
  • 43