Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

gzip huge file(~30G) in PHP

Tags:

php

does any of you have some experience with compressing huge file in PHP using "gzcompress" ? more efficient is compress the same file in a shell using tar ? To be more exact : such huge file is gzipped directly in PHP. PHP script is running via cron job everyday. My intuition tells me this is slower than executing tar directly in a system shell. But this is still my intuition only :) Question is if it's slower ? If yes than how big the differences can be ? Differences especially when we are talking about execution time.

like image 695
Robert Avatar asked Jan 22 '26 10:01

Robert


2 Answers

It doesn't seem like a PHP web job to me. Is this getting gzipped on demand for delivery or transfer? I would put that sort of thing in a queue for processing by a cron job in the shell.

like image 170
Jordan Avatar answered Jan 24 '26 23:01

Jordan


PHP isn't going to be any faster than tar + gzip, and will be much more taxing on your web serving process. I'd redesign the application to add the gzip request to a queue (database, filesystem, whatever), return immediately with "your request is in the works...", and meta refresh the page every N seconds until another process (cron job) has done the work, then return a download link to the completed binary.

like image 40
Bryan Boettcher Avatar answered Jan 24 '26 23:01

Bryan Boettcher



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!