Re: [PHP] Is flock() necessary on a simple file append?
Paul Fierro [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] On 10/24/2004 5:11 PM, Kevin Grigorenko [EMAIL PROTECTED] wrote: I am appending to a file one line of text on every page hit, so there could be many occurrences of this append simultaneously. I am not opening for write (w) but for append (a). Do I need to use flock() to be sure there are no issues? I am running on Solaris. On 10/24/2004 5:39 PM, Hristo Yankov [EMAIL PROTECTED] wrote: append is the same as write (it requires write access for example), so if you are gonna use flock for w, use it for a too. According to this post, you do not need to use flock() if you open a file in append mode: http://marc.theaimsgroup.com/?l=php-generalm=105165806915109w=2 That's exactly what I was looking for; however, I wonder whether that only applies to the one byte the poster speaks of, or as long as everyone is only appending. Paul Kevin Grigorenko -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] MySQL Scalability, part 2
Hi, First, sorry for posting an attachment. Second, I fixed my problem to use files, but I just had a general question: Is it really scalable to use MySQL on every page hit as compared to writing to files? Is it true that it only has a certain number of connections it can open at a time (20-30?), and the contention is larger? Thanks, Kevin -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Is flock() necessary on a simple file append?
Hi, I am appending to a file one line of text on every page hit, so there could be many occurrences of this append simultaneously. I am not opening for write (w) but for append (a). Do I need to use flock() to be sure there are no issues? I am running on Solaris. Thanks, Kevin -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] MySQL Scalability, part 2
Zareef Ahmed [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] -Original Message- From: Kevin Grigorenko [mailto:[EMAIL PROTECTED] Sent: Monday, October 25, 2004 12:36 AM To: [EMAIL PROTECTED] Subject: [PHP] MySQL Scalability, part 2 Hi, First, sorry for posting an attachment. Second, I fixed my problem to use files, but I just had a general question: Is it really scalable to use MySQL on every page hit as compared to writing to files? Is it true that it only has a certain number of connections it can open at a time (20-30?), and the contention is larger? [] Yes mysql is much faster than file writing. And you can open multiple connection to it. What is this statement based on? I'm absolutely not questioning you, I am just skeptical (if you have any websites or performance benchmarks, please provide). It's hard for me to imagine that a file system access (let alone appending one line to the end of a file) is slower than a MySQL execution. Even if we assume that MySQL does everything in memory, here are just some of the things that have to happen: 1. A MySQL connection may be opened. Perhaps there is connection pooling, and this isn't too bad, just finds a reference to an already open MySQL connection. Performance hit ~ 0 2. mysql_query is executed, which first must go through the PHP library, then connect to a socket (perhaps on another server, but we'll assume on the same server for now). Performance hit ~ negligible if the mysql daemon is on the same server 3. The mysql daemon then has to process this request along with whatever load is already on the daemon, then needs to get locks on the table to insert into it. Performance hit ~ could be a lot, I doubt MySQL is faster at locking than flock() 4. MySQL has to probably do a lot of in memory operations and then send the result back over the socket. But if you have some webpages that prove otherwise, i will be VERY GLAD to see them, because mysql sure makes everything much easier. I just can't see it yet based on such a simple statement as above. Visit http://dev.mysql.com/doc/mysql/en/Too_many_connections.html Thanks, Kevin -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Zareef Ahmed :: A PHP develoepr in Delhi ( India ) Homepage :: http://www.zasaifi.com --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.782 / Virus Database: 528 - Release Date: 10/22/2004 Thank you, Kevin Grigorenko -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] MySQL Scalability, part 2
Kevin Grigorenko [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Zareef Ahmed [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] -Original Message- From: Kevin Grigorenko [mailto:[EMAIL PROTECTED] Sent: Monday, October 25, 2004 12:36 AM To: [EMAIL PROTECTED] Subject: [PHP] MySQL Scalability, part 2 Hi, First, sorry for posting an attachment. Second, I fixed my problem to use files, but I just had a general question: Is it really scalable to use MySQL on every page hit as compared to writing to files? Is it true that it only has a certain number of connections it can open at a time (20-30?), and the contention is larger? [] Yes mysql is much faster than file writing. Just to clarify, my response was based on this part of your answer, not the open connections part. Thank you for that link explaining the open connections piece of it. My response was in response to the fact that it is faster than file writing. Sorry if there was confusion. And you can open multiple connection to it. What is this statement based on?I'm absolutely not questioning you, I am just skeptical (if you have any websites or performance benchmarks, please provide). It's hard for me to imagine that a file system access (let alone appending one line to the end of a file) is slower than a MySQL execution. Even if we assume that MySQL does everything in memory, here are just some of the things that have to happen: 1. A MySQL connection may be opened. Perhaps there is connection pooling, and this isn't too bad, just finds a reference to an already open MySQL connection. Performance hit ~ 0 2. mysql_query is executed, which first must go through the PHP library, then connect to a socket (perhaps on another server, but we'll assume on the same server for now). Performance hit ~ negligible if the mysql daemon is on the same server 3. The mysql daemon then has to process this request along with whatever load is already on the daemon, then needs to get locks on the table to insert into it. Performance hit ~ could be a lot, I doubt MySQL is faster at locking than flock() 4. MySQL has to probably do a lot of in memory operations and then send the result back over the socket. But if you have some webpages that prove otherwise, i will be VERY GLAD to see them, because mysql sure makes everything much easier. I just can't see it yet based on such a simple statement as above. Visit http://dev.mysql.com/doc/mysql/en/Too_many_connections.html Thanks, Kevin -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Zareef Ahmed :: A PHP develoepr in Delhi ( India ) Homepage :: http://www.zasaifi.com --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.782 / Virus Database: 528 - Release Date: 10/22/2004 Thank you, Kevin Grigorenko Kevin -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] MySQL scalability...
John Holmes [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Kevin Grigorenko wrote: Unfortunately, for some security issues, I cannot get to the Apache statistics for the site, so I have to create my own solution. I recommend you find a better host that gives you access to the raw logs and/or doesn't have safe_mode on. I wish it was that easy. I'm actually a college student working on the dean's webpage, and there is a mammoth server which hosts all of the university's sites, and so they have put really strict restrictions. Perhaps it is not even a problem because of safe_mode, but I have tried many different things to try to get around it, including ini_set(), but nothing has worked. I get Permission Denied errors. -- ---John Holmes... Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/ php|architect: The Magazine for PHP Professionals www.phparch.com Kevin Grigorenko -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: MySQL scalability...
Kevin Grigorenko [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Hello, Now, I just found out after implementing this whole solution locally that when I uploaded to the server, the PHP safe_mode options are on, and non-overwritable. Therefore, fopen() doesn't even work! Well, I just figured out my own problem. The problem was these files didn't exist, and it couldn't create them the first time because I guess the script didn't have write access to the directory. I thought I checked for this possibility before by touching the file, but I must have forgotten to set write permissions to the 'other' group. Are there any pitfalls in setting the directory to write permissions for other, or should I just create all of these files individually and set their write permissions atomically? Sorry about that, Thanks, Kevin Grigorenko -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php