I created a WEB program using .NET 8 MVC and adopted Aspose.Slides. Instead of the NuGet version, I used the release version from the official website. Currently, I’ve found that when using the AddClone function of Slides in Docker, the performance is extremely low. This operation takes about 10 seconds on the development machine, but in Docker, it may take 5-10 minutes. I’d like to know the cause of this issue.
My dockerfile:
The performance issue you’re experiencing with Aspose.Slides in a Docker environment compared to your development machine can be attributed to several factors. Docker containers may have different resource allocations, and the environment might not be optimized for performance. Additionally, the libraries and dependencies used in your Docker image might not be fully compatible or optimized for the .NET 8 runtime.
Solution
To improve performance, follow these steps:
Resource Allocation: Ensure that your Docker container has sufficient CPU and memory allocated. Adjust these settings in your Docker configuration.
Use the Latest Version: Confirm that you are using the latest version of Aspose.Slides, as performance improvements and bug fixes are often included in newer releases.
Optimize Dockerfile: Review your Dockerfile for unnecessary installations or configurations that could slow down the container. For example, if you don’t need LibreOffice or Python dependencies, consider removing them.
Profile Your Application: Utilize profiling tools to identify bottlenecks in your application. This will help you determine whether the issue lies within the Aspose.Slides library or elsewhere in your code.
Run in a Different Environment: If feasible, test your application outside of Docker to compare performance. This will help ascertain if the issue is specific to the Docker environment.
Code
Here’s a minimal example of how you might structure your Dockerfile to focus on performance:
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
WORKDIR /app
COPY ["PPTWeb.csproj", "."]
RUN dotnet restore
COPY . .
RUN dotnet publish -c Release -o /app/publish
FROM mcr.microsoft.com/dotnet/aspnet:8.0
WORKDIR /app
COPY --from=build /app/publish .
ENV ASPNETCORE_ENVIRONMENT=Production
ENV ASPNETCORE_URLS=http://+:8080
EXPOSE 8080
ENTRYPOINT ["dotnet", "PPTWeb.dll"]
Next Steps
Adjust the resource limits for your Docker container.
Test performance with the latest version of Aspose.Slides.
Profile your application to identify performance bottlenecks.
Consider running your application outside of Docker for comparison.
Please implement these steps and let me know if you need further assistance!
I have also conducted the same demo on a Windows server with identical configurations, and the result remains consistent with the development environment, demonstrating fast speed. I still suspect that the performance issue is related to the “.so” files in the release version.
for (int i = 0; i < list.Count; i++)
{
if (i == 0 || currSort != list[i].Sort)
{
currSort = list[i].Sort;
destPresentation.Slides.AddClone(templateSlides[currSort]);//目录
}
var data = list[i];
var filedata = allFileData[data.FileID];
var slides = filedata.Slides;
**destPresentation.Slides.AddClone(slides[data.PageNum - 1]); **//This line of code is slow
}
@id2700,
Thank you for contacting free support. We are sorry that you encountered this problem. We need more details to investigate the case. Please share the following additional files and information:
Thank you for your help. I am using Aspose.Slides, Version=25.6.0.0, Culture=neutral, PublicKeyToken=716fcc553a201e56. However, I’m sorry that I cannot provide the presentation file due to confidential information. I can only confirm that all elements in the presentation are original without any plugins or additional components, consisting mainly of numerous images and text contents.
@id2700,
Thank you for the additional information. Unfortunately, we need the sample presentation file to investigate the case. It would be helpful if you could remove the confidential information from the presentation and share the file.
When there are an especially large number of page elements, such as a single PPT page containing dozens of different boxes with text in each, the copying speed in Docker will be very slow.
@andrey.potapov hi demo - 副本.zip (3.0 MB)
This file can be copied within 1-2 seconds under the Windows system, but it takes 10 seconds or more in Docker.
@id2700,
Thank you for the sample presentation file. Unfortunately, I was unable to use your code example and reproduce the issue you described. With Aspose.Slides for .NET 25.6, I used the following code example:
using var templateSlides = new Presentation("demo - copy.pptx");
var slide = templateSlides.Slides[0];
using var destPresentation = new Presentation();
Stopwatch stopwatch = new Stopwatch();
stopwatch.Start();
destPresentation.Slides.AddClone(slide);
stopwatch.Stop();
var elapsedSeconds = stopwatch.ElapsedMilliseconds / 1000;
Console.WriteLine($"Clone time: {elapsedSeconds} seconds");
Dockerfile:
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
WORKDIR /source
COPY *.csproj .
RUN dotnet restore
COPY . .
RUN dotnet publish -o /app
FROM mcr.microsoft.com/dotnet/aspnet:8.0
RUN apt-get update && apt-get install -y \
libfontconfig1 \
libfreetype6
WORKDIR /app
COPY --from=build /app .
ENTRYPOINT ["./NetcoreApp"]
Output:
Clone time: 0 seconds
The method AddClone completed in less than a second. Please check the issue carefully again and isolate the problem.
Cookie Notice
To provide you with the best experience, we use cookies for personalization, analytics, and ads. By using our site, you agree to our cookie policy.
Enables storage, such as cookies, related to analytics.
Sets consent for sending user data to Google for online advertising purposes.
Sets consent for personalized advertising.
Cookie Notice
To provide you with the best experience, we use cookies for personalization, analytics, and ads. By using our site, you agree to our cookie policy.
More info
Enables storage, such as cookies, related to analytics.
Enables storage, such as cookies, related to advertising.
Sets consent for sending user data to Google for online advertising purposes.
Sets consent for personalized advertising.
Cookie Notice
To provide you with the best experience, we use cookies for personalization, analytics, and ads. By using our site, you agree to our cookie policy.
More info
Enables storage, such as cookies, related to analytics.
Enables storage, such as cookies, related to advertising.
Sets consent for sending user data to Google for online advertising purposes.