Listening for Multiple Requests at a same time (Android to Python Script).

Ak Ak 1 Reputation point
2020-10-09T18:40:49.537+00:00

Just point me in the right direction, please. I have no idea how to deal with this. Also, I am a complete newbie so don't judge me too.

So, I want to connect my scraping script written in Python, connected to a front-end Android app. I have already written the script and front-end is ready as well. However, I dont know how these two things would communicate with each other, in which the script constantly listens for requests from the Android App.
However, there is one more thing. Since multiple users would use the app at the same time, so there will be parallel requests sent from the App as well. How do I let the script to process the requests concurrently without waiting for first one to be completed. All the scraping is done through requests library. Can I use Azure Functions in such case?

Kindly tell me which way do I go?

Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
4,231 questions
Azure Logic Apps
Azure Logic Apps
An Azure service that automates the access and use of data across clouds without writing code.
2,836 questions
{count} votes

1 answer

Sort by: Most helpful
  1. JayaC-MSFT 5,526 Reputation points
    2020-10-13T05:37:01.793+00:00

    @Ak Ak In the given scenario, you can put the script in an azure python function and make a call to it whenever required. However, as you mentioned there will be multiple parallel request which might pose a warning due to the single threaded architecture of Python.
    It is documented in our Python Functions Developer reference on how to handle such scenario’s: functions-reference-python ( also check asyncio-eventloop )

    Here are methods to handle this:

    1. Use Async calls
    2. Add more Language worker processes per host, this can be done by using application setting : FUNCTIONS_WORKER_PROCESS_COUNT upto a maximum value of 10.

    [Please note that each new language worker is spawned every 10 seconds until they are warm.]

    Here is a GitHub issue which talks about this issue in detail : https://github.com/Azure/azure-functions-python-worker/issues/236

    Please let me know if this helps and answers your question. If yes , please "accept the answer" and "up-vote" so that it helps others in the community.

    0 comments No comments