Optimizing Performance: entityframework-extensions.net with Virto Commerce Platform

In this post, I want to describe how to turbocharge Virto Commerce performance and efficiency! With the integration of the entityframework-extensions.net library, we have unlocked a powerful feature that will significantly enhance your data storage and retrieval processes, resulting in faster and more streamlined operations.

:mag: How It Works

The entityframework-extensions.net library brings high-performance batch and bulk operations. With BulkSave, you can process multiple entities in a single transaction, rather than performing individual operations, significantly reducing the overhead associated with storing and retrieving data.

:bulb:The Power of BulkSave

By using BulkSave, we’ve witnessed substantial performance improvements across various operations within the platform, primary for Cart and Order operations.

image

:factory: Implementation Details

To integrate the entityframework-extensions.net library, you will need to create a new vc module and configure the library to enable this feature. Additionally, you need to create DbContextWithBulkSaveChangesUnitOfWork class, extending the DbContextUnitOfWork to leverage the BulkSave capabilities.

public class DbContextWithBulkSaveChangesUnitOfWork : DbContextUnitOfWork
{
    public DbContextWithBulkSaveChangesUnitOfWork(DbContext context) : base(context)
    {

    }

    public async override Task<int> CommitAsync()
    {
        await base.DbContext.BulkSaveChangesAsync();
        return 1;
    }

    public override int Commit()
    {
        base.DbContext.BulkSaveChanges();
        return 1;
    }
}

And override DbContextUnitOfWork type with DbContextWithBulkSaveChangesUnitOfWork in Module.Initialize method. That’s all folks.

public class Module: IModule, IHasConfiguration
{
 ...
    public void Initialize(IServiceCollection serviceCollection)
    {
        // Override models
        AbstractTypeFactory<DbContextUnitOfWork>.OverrideType<DbContextUnitOfWork, DbContextWithBulkSaveChangesUnitOfWork>();
    }
 ...
}

:mag: Test Results

To illustrate the impressive impact of the entityframework-extensions.net integration, we conducted tests to compare operations with and without BulkSave, we use a small instance in Virto Cloud, up to 20 products in the cart and 100 users simultaneously. The results were remarkable, showcasing substantial time reductions for various actions:

XAPI Operation Native, ms Using extensions, ms Diff, ms
Add To Cart 810 656 -154
Merge Cart 1178 783 -395
Add Payment 781 676 -105
Update Payment 816 719 -97
Create Order 1017 790 -227

:chart_with_upwards_trend: Embrace the Power of entityframework-extensions.net

With the implementation of the entityframework-extensions.net library, the Virto Commerce Platform has taken a giant leap forward in performance optimization. We are confident that you will appreciate the enhanced speed and efficiency it brings to your e-commerce operations.

:bulb:Note

Please be aware that the entityframework-extensions.net library is a paid feature. However, the immense benefits it delivers are well worth the investment, especially if you prioritize seamless user experiences and top-notch performance.

I think about the same result can be obtained when switching to .NET7
dotnet-7-updates-and-nopcommerce-performance
And with the release of .NET 8, the result will be even more exciting!

We’re also eagerly anticipating the release of .NET 8.

At Virto Commerce, we prioritize the use of .NET LTS (Long-Term Support) versions for our development. This approach ensures that our solutions remain stable, secure, and well-supported. By choosing .NET LTS, we can provide our users with a consistent and reliable experience, and we’re excited to continue this commitment as we plan to transition Virto Commerce to .NET 8 in January 2023.

The advancements in performance and features that .NET 8 promises are indeed exciting, and we’re looking forward to leveraging them to enhance our platform further.

1 Like

I wonder if there are any performance differences when using postgresql (or its more perfect counterpart YugabyteDB) instead of mssql?

We already have internal DB comparison results from our partners and internal environments but before publishing it should be enriched with more data like Hosting Cost, Maintenance, etc. We will publish it soon.

PS: Performance of any DB, can be killed easily by wrong configuration and maintenances.

1 Like