PHP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingPHP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
Free Web 2.0 Code Generator! Generate data entry and reporting .NET Web apps in minutes. Quickly create visually stunning, feature-rich apps that are easy to customize and ready to deploy. Download Now!
  #1  
Old September 7th, 2004, 05:04 AM
tim tim is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jun 2002
Posts: 62 tim User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 12 m 9 sec
Reputation Power: 7
Send a message via ICQ to tim
Parsing a 700MB log file

Hi,

I have a log file which is 700MB in size and has lines and lines of information, separated by carriage returns, with the values in each line separated by commas.

I'm suppose to read through line by line of it before inserting the information in the database. Problem is, after I hit the upload button, I get a "The page cannot be displayed" page and got hang right at where the script parses through the file, while at other times my progress bar goes blinking and nothing happens.

I have these set in my PHP 4.3.6's ini file
max_execution_time = 180 ;
max_input_time = 120 ;
memory_limit = 8M
upload_max_filesize = 800M

What's the problem? Is it impossible to upload a 700MB file?
__________________
Beginner

Reply With Quote
  #2  
Old September 7th, 2004, 06:03 AM
kode_monkey kode_monkey is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Posts: 367 kode_monkey User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 7 m 21 sec
Reputation Power: 6
I have no idea but it strikes me as a bad idea. What kind of connection would you be uploading it over? For something like this you'd be better off doing it in c/c++ rather than php I think since it has good mysql access (I'm presuming thats your db) but won't cry when you show it the file.

-KM-

Reply With Quote
  #3  
Old September 7th, 2004, 11:27 AM
Itsacon's Avatar
Itsacon Itsacon is offline
Command Line Warrior
Click here for more information
 
Join Date: Aug 2004
Location: Sector ZZ9 Plural Z Alpha
Posts: 956 Itsacon User rank is Lance Corporal (50 - 100 Reputation Level)Itsacon User rank is Lance Corporal (50 - 100 Reputation Level)Itsacon User rank is Lance Corporal (50 - 100 Reputation Level)  Folding Points: 682581 Folding Title: Super Ultimate Folder - Level 2Folding Points: 682581 Folding Title: Super Ultimate Folder - Level 2Folding Points: 682581 Folding Title: Super Ultimate Folder - Level 2Folding Points: 682581 Folding Title: Super Ultimate Folder - Level 2Folding Points: 682581 Folding Title: Super Ultimate Folder - Level 2Folding Points: 682581 Folding Title: Super Ultimate Folder - Level 2Folding Points: 682581 Folding Title: Super Ultimate Folder - Level 2
Time spent in forums: 6 Days 8 h 23 m 34 sec
Reputation Power: 4
Send a message via ICQ to Itsacon
Alternatively, you could upload the log file by ftp (or whatever method you upload your php files with) and access it through the fopen() command. This way, you don't need to read the entire file at once, which is probably the problem, considering the 8MB memory limit to the php parser.
fgets() is ideal for log files, especially with ini_set("auto_detect_line_endings", "1");

good luck.

Reply With Quote
  #4  
Old September 7th, 2004, 08:28 PM
tim tim is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jun 2002
Posts: 62 tim User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 12 m 9 sec
Reputation Power: 7
Send a message via ICQ to tim
Yup, my db is MySQL and indeed I'm using fgets() to read the line and have set my ini_set("auto_detect_line_endings", "1");

kode_monkey, what do you mean what kind of connection I'll be uploading it over? CUrrently, I'm only testing it localhost. I'm not even attempting to insert the read line into db yet, I'm just merely trying to echo out all the read lines on screen, just for testing.

Itsacon, is it possible to increase my 8M memory limit of php parser without any performance degradation? Or is this recommended?

Basically, I'm trying to build a web-based reporting tool that imports log file to be analyzed. Hence, I would like to have the users upload the log files themselves using <input type=file> and not use other ftp programs to do it (which understandably is much easier)

Reply With Quote
  #5  
Old September 8th, 2004, 12:39 AM
Itsacon's Avatar
Itsacon Itsacon is offline
Command Line Warrior
Click here for more information
 
Join Date: Aug 2004
Location: Sector ZZ9 Plural Z Alpha
Posts: 956 Itsacon User rank is Lance Corporal (50 - 100 Reputation Level)Itsacon User rank is Lance Corporal (50 - 100 Reputation Level)Itsacon User rank is Lance Corporal (50 - 100 Reputation Level)  Folding Points: 682581 Folding Title: Super Ultimate Folder - Level 2Folding Points: 682581 Folding Title: Super Ultimate Folder - Level 2Folding Points: 682581 Folding Title: Super Ultimate Folder - Level 2Folding Points: 682581 Folding Title: Super Ultimate Folder - Level 2Folding Points: 682581 Folding Title: Super Ultimate Folder - Level 2Folding Points: 682581 Folding Title: Super Ultimate Folder - Level 2Folding Points: 682581 Folding Title: Super Ultimate Folder - Level 2
Time spent in forums: 6 Days 8 h 23 m 34 sec
Reputation Power: 4
Send a message via ICQ to Itsacon
Wouldn't really know about the mem limit, no doubt you can increase it, but it might increase the system load PHP generates.
I'd say make a benchmark program, and test the two settings.

As for uploading log files, my server logs each day in another file, so log files of 700 MB are rather uncommon (non-existent, in fact), so for now I'd decrease the size for a bit and get the program working. If all's fine, increase the size by small steps and see when it blows.
Don't forget to test on multiple systems, as this behaviour may vary between different OS.

Reply With Quote
  #6  
Old September 8th, 2004, 03:08 AM
kode_monkey kode_monkey is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Posts: 367 kode_monkey User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 7 m 21 sec
Reputation Power: 6
Well uploading a file of that size (even over a lan) will take a non-negligable amount of time. You may want to run some tests to find out if the script is timing out before the upload completes. Since php was written for webpages I doubt anyone intended it to be used for something that large and thus you may need to tweek you settings some.

Thats not to say its a bad idea mind. I'm sure with a few tweeks here and there it'll work out nicely,

-KM-

Reply With Quote
  #7  
Old September 8th, 2004, 11:32 AM
Itsacon's Avatar
Itsacon Itsacon is offline
Command Line Warrior
Click here for more information
 
Join Date: Aug 2004
Location: Sector ZZ9 Plural Z Alpha
Posts: 956 Itsacon User rank is Lance Corporal (50 - 100 Reputation Level)Itsacon User rank is Lance Corporal (50 - 100 Reputation Level)Itsacon User rank is Lance Corporal (50 - 100 Reputation Level)  Folding Points: 682581 Folding Title: Super Ultimate Folder - Level 2Folding Points: 682581 Folding Title: Super Ultimate Folder - Level 2Folding Points: 682581 Folding Title: Super Ultimate Folder - Level 2Folding Points: 682581 Folding Title: Super Ultimate Folder - Level 2Folding Points: 682581 Folding Title: Super Ultimate Folder - Level 2Folding Points: 682581 Folding Title: Super Ultimate Folder - Level 2Folding Points: 682581 Folding Title: Super Ultimate Folder - Level 2
Time spent in forums: 6 Days 8 h 23 m 34 sec
Reputation Power: 4
Send a message via ICQ to Itsacon
Another possibility is to have people submit the files in a compressed format, and read them from PHP using the ZLib Library.

My experience is that text files (especially files with many identical parts, like log files) compress very well, so this may enable you to keep the logfile size limit a bit higher.

Reply With Quote
  #8  
Old September 8th, 2004, 07:03 PM
tim tim is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jun 2002
Posts: 62 tim User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 12 m 9 sec
Reputation Power: 7
Send a message via ICQ to tim
Hm...yeah, ok, will try out and see how. Thanks. Will keep you guys posted....

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingPHP Development > Parsing a 700MB log file


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway