search
HomeBackend DevelopmentPython TutorialPolars Delta Lake: Azure Function vs. Laptop on Small Data

Polars   Delta Lake: Azure Function vs. Laptop on Small Data

Have you ever wondered how the performance of Polars Deltalake on Azure compares to a consumer grade laptop?
No? Well, I have. If I have sparked your curiosity, read on.

Here are the contenders

  1. EliteBook 840 G10, AMD Ryzen 7840U, 8 cores, 16 threads, 64 GB RAM
  2. Azure Function running on a Linux B3 SKU app service plan (4 cores, 7 GB RAM)
    • with standard ADLS2 storage
    • with premium ADLS2 storage

See Pricing for a full list of available app service plans.

Test Setup

The test measures three scenarios

  1. create delta table
  2. write to delta table
  3. read from delta table

The code is executed via REST API endpoints:

  1. polars_azure_create: https://function-hekori-learning-002.azurewebsites.net/api/polars/azure/create
  2. polars_azure_read: https://function-hekori-learning-002.azurewebsites.net/api/polars/azure/read
  3. polars_azure_write: https://function-hekori-learning-002.azurewebsites.net/api/polars/azure/write
  4. polars_local_create: http://localhost:7071/api/polars/local/create
  5. polars_local_read: http://localhost:7071/api/polars/local/read
  6. polars_local_write: http://localhost:7071/api/polars/local/write

On the HP EliteBook I used func start to launch https://localhost:7071.
To publish to Azure I, followed the instructions from https://learn.microsoft.com/en-us/azure/azure-functions/create-first-function-cli-python
to set up the necessary development environment. This allowed me to publish the function via
func azure functionapp publish function-hekori-learning-002.

I used terraform to set up the Azure resources in the North Europe region.

Here is a code snippet showing the code executed when visiting https://function-hekori-learning-002.azurewebsites.net/api/polars/azure/read

@app.route(route="polars/azure/read", auth_level=func.AuthLevel.ANONYMOUS)
def polars_azure_read(req: func.HttpRequest) -> func.HttpResponse:
    logging.info('Reading from delta table')

    tic = time.time()
    df = pl.read_delta(AZURE_STORAGE_PATH, storage_options=storage_options
                       )

    df = df.sql(
        "select sum(value) as sum, avg(value) as mean, count() as count, name from self group by name order by sum asc"
    )

    toc = time.time()

    logging.info(f"Elapsed time {toc - tic:.2f} seconds")

    return func.HttpResponse(
        "Success from polars." + str(df) + '\n' + "Elapsed time " + str(toc - tic) + " seconds",
        status_code=200
    )

Test Results

As one can see the HP EliteBook is roughly one order of magnitude faster in all scenarios.

Polars   Delta Lake: Azure Function vs. Laptop on Small Data

Interpretation

This is my personal interpretation

  1. The Azure Function timings are sufficient for synchronous tasks. E.g., to be used in POST requests where the client expects a response in
  2. If you have small data and want the best performance, you should consider running Polars on bare metal or virtual machine with low IO latency.

Please note that the delta table has a small size of 3 commits and 2 parquet files. I.e., the runtime effectively measure the overhead of the file access from the compute unit.

If you ❤️ this article and want to see more benchmark results with larger datasets for out of core processing give this article a ?
and subscribe ? to my channel ???.

The above is the detailed content of Polars Delta Lake: Azure Function vs. Laptop on Small Data. For more information, please follow other related articles on the PHP Chinese website!

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
What is Python Switch Statement?What is Python Switch Statement?Apr 30, 2025 pm 02:08 PM

The article discusses Python's new "match" statement introduced in version 3.10, which serves as an equivalent to switch statements in other languages. It enhances code readability and offers performance benefits over traditional if-elif-el

What are Exception Groups in Python?What are Exception Groups in Python?Apr 30, 2025 pm 02:07 PM

Exception Groups in Python 3.11 allow handling multiple exceptions simultaneously, improving error management in concurrent scenarios and complex operations.

What are Function Annotations in Python?What are Function Annotations in Python?Apr 30, 2025 pm 02:06 PM

Function annotations in Python add metadata to functions for type checking, documentation, and IDE support. They enhance code readability, maintenance, and are crucial in API development, data science, and library creation.

What are unit tests in Python?What are unit tests in Python?Apr 30, 2025 pm 02:05 PM

The article discusses unit tests in Python, their benefits, and how to write them effectively. It highlights tools like unittest and pytest for testing.

What are Access Specifiers in Python?What are Access Specifiers in Python?Apr 30, 2025 pm 02:03 PM

Article discusses access specifiers in Python, which use naming conventions to indicate visibility of class members, rather than strict enforcement.

What is __init__() in Python and how does self play a role in it?What is __init__() in Python and how does self play a role in it?Apr 30, 2025 pm 02:02 PM

Article discusses Python's \_\_init\_\_() method and self's role in initializing object attributes. Other class methods and inheritance's impact on \_\_init\_\_() are also covered.

What is the difference between @classmethod, @staticmethod and instance methods in Python?What is the difference between @classmethod, @staticmethod and instance methods in Python?Apr 30, 2025 pm 02:01 PM

The article discusses the differences between @classmethod, @staticmethod, and instance methods in Python, detailing their properties, use cases, and benefits. It explains how to choose the right method type based on the required functionality and da

How do you append elements to a Python array?How do you append elements to a Python array?Apr 30, 2025 am 12:19 AM

InPython,youappendelementstoalistusingtheappend()method.1)Useappend()forsingleelements:my_list.append(4).2)Useextend()or =formultipleelements:my_list.extend(another_list)ormy_list =[4,5,6].3)Useinsert()forspecificpositions:my_list.insert(1,5).Beaware

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Safe Exam Browser

Safe Exam Browser

Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

EditPlus Chinese cracked version

EditPlus Chinese cracked version

Small size, syntax highlighting, does not support code prompt function

SublimeText3 Linux new version

SublimeText3 Linux new version

SublimeText3 Linux latest version

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool