dongshen7407 2012-12-13 07:22
浏览 47

提高文件写入速度

I have created a website in which there is a Checkout button, whenever the Customer Clicks on the Checkout Button I need to create 4 Image Files in jpg Format and Save them on the Server. These Image Files will be later on printed by the Admin of the Site

Now one of the Image Files could be of 3MB to 4MB in size While the rest of the 3 Images Files will be mostly between 250KB to 500KB in size

Now the problem is the First File which could be from 3MB to 4MB takes some time to be created like 5-10 Secs (this is only when one Customer Checkout at a time)

But when I performed simultaneous Checkout with 2 different Devices, the time frame increased to 20 Secs, one of the Checkout was processed First while the other waited or worked a little slowly, so the total time was 20 Secs, otherwise the time for one of the Checkout was 8 Secs while for the other it was 12 Secs

So I fear that if 10 or 20 Customers performed Checkout simultaneously then some of them might have to wait for perhaps 2 OR 3 Mins or perhaps even more

So can anyone please tell me, how I can increase the rate at which PHP writes file OR to increase the PHP Execution Speed OR Will increasing the RAM might help (currently it is 1GB)

Note :-
->I am using IMagick to create Image Files,
->Also cannot reduce the jpg quality as it will be printer later on at 150 dpi,
->The First Image File is a High Definition Photograph, while the rest 3 are only filled with Solid Colors
->Also their resolutions are High like between 2800 to 4400 pixels in both width and height
->Also there is a Serial Number that is to be added to all 4 Image Files so I cannot reduce it's quality otherwise the Serial Number might not be visible while printing all the 4 Image Files

UPDATE : The Customer First Uploads a Photograph, then he can scale the image, crop it or even move it(for cropping purpose)

So in short he is mainly cropping an uploaded image and when he Clicks on the Checkout Button the new image is created and a Serial Number is added to it

I checked the code the Image gets processed OR created in memory(RAM) in about 1 Sec, but when I add the code for writing the image on the Hard Drive in the Server itself it is then that it takes some amount of time 5-8 Secs if no simultaneous request or 10-15 Mins if 20-30 Simultaneous Request

Also I have to show them a Success or a Failure Message, but I can only show the Success Message after all the 4 images files are created, so even if i use ajax even then I cannot show the Success Message not before all the Images are created

Again if I remove the code for writing the Image then the time reduces to 1 Sec if no simultaneous request or 5-10 Secs if 20-30 Simultaneous Request

So I think the problem is with writing the Image File and not processing or generating it

Also I cannot create the Image File while the user is still cropping the image otherwise it will slow down the cropping process. Also the situation will not change but rather get worse, the problem from "What will happen when Simultaneous Checkout" will change to "What will happen when Simultaneous Crop". So this is not an option

Also I don't think it will look professional if I say that an EMail will be sent to you, informing you whether your Checkout was a Success or Not.

  • 写回答

1条回答 默认 最新

  • douqianxun8540 2012-12-13 07:35
    关注

    Just a few thoughts, maybe one of them help you with your task at hand:

    • Try to find out which of the steps you are performing on those images is the one eating away your performance. Maybe show some code, so people can help.
    • Some image operations might take longer because of older hardware (CPU, RAM, HD). Is your hardware good enough?
    • Are you using the latest version of IMagick?
    • Try separating the image processing from the checkout process. Maybe write the raw data into a database, file or whatever first and create a cron (or trigger it) which does the processing, so your users don't have to wait for this.
    • You might have to delve into your php and apache configuration, too. Unoptimized setups might result into performance issues, too.
    评论

报告相同问题?

悬赏问题

  • ¥15 java 操作 elasticsearch 8.1 实现 索引的重建
  • ¥15 数据可视化Python
  • ¥15 要给毕业设计添加扫码登录的功能!!有偿
  • ¥15 kafka 分区副本增加会导致消息丢失或者不可用吗?
  • ¥15 微信公众号自制会员卡没有收款渠道啊
  • ¥15 stable diffusion
  • ¥100 Jenkins自动化部署—悬赏100元
  • ¥15 关于#python#的问题:求帮写python代码
  • ¥20 MATLAB画图图形出现上下震荡的线条
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘