Ok, I have a nice iface, I have a (hopefully) good user authentication, I
have a DB up-and-running, and I have PHP 4.3.4 (yeah, I know, I will
update...).
What I need is a logging utility. And the question is: where to keep the
logs?
We (me and my buddy) have written everything from scratch (including
sessions support) - in a quest to learn something useful. Now we need to
decide where to keep our logs?
We can either keep them in a DB (already running, so no
setup/configuration needed here), or in a file.
Obviously, the file has an advantage over the DB - no overhead, less
queries. But here's the bad part: there will be ~500 users using this
site. It most certainly *will* happen that a few will use it
simultaneously.
So, we can flock() the file. Great. I can see the queue getting dreadfuly
long, the execution time getting dangerously near the limit and the
users getting mad on the other side of the cable.
Well, we don't have to flock() it. Fantastic - I can just imagine what
will happen if ~10 instaces of the script will try to write to this file
simultaneously. ..
Ok, we can can even write a "utility" script, that will get invoked by
the other scripts (with fopen(), not include()) and will do the actual
logging. But - isn't that just a other way for flock()? :)
Well, why don't we use the DB? Oh, right - the overhead...
Any ideas? I'm run out of mine...
Cheers
Mike 8 1829
On 2005-04-22, Micha³ Wo¼niak
<mikiwoz_remove _this@yahoo_rem ove_this.co.uk> wrote: So, we can flock() the file. Great. I can see the queue getting dreadfuly long, the execution time getting dangerously near the limit and the users getting mad on the other side of the cable.
If you only flock() it for the split second it actually is needed to
open and write to the log file you shouldn't see that kind of problem.
Even with 500 concurrent users (that is 500 people visiting your site at
the same time, not 500 concurrent requests) you should have plenty of
capacity to spare.
--
Cheers,
- Jacob Atzen
One quick glance of an experienced eye allowed to understand the blurred
and almost unreadable Jacob Atzen's handwriting: On 2005-04-22, Micha? Wo?niak <mikiwoz_remove _this@yahoo_rem ove_this.co.uk> wrote: So, we can flock() the file. Great. I can see the queue getting dreadfuly long, the execution time getting dangerously near the limit and the users getting mad on the other side of the cable.
If you only flock() it for the split second it actually is needed to open and write to the log file you shouldn't see that kind of problem. Even with 500 concurrent users (that is 500 people visiting your site at the same time, not 500 concurrent requests) you should have plenty of capacity to spare.
Still not convinced, as there will be multiple write aactions to the file
per request...
Cheers
Mike
One more idea: syslog().
The only problem is: I don't want to have those logs in
the /var/log/syslog file, I'd rather having them in /some/other/file -
is it possible? Couldn't find anything on this on php.net :/
TIA
Mike
=?ISO-8859-2?Q?Micha=B3_Wo =BCniak?= (mikiwoz_remove _this@yahoo_rem ove_this.co.uk) wrote:
: Ok, I have a nice iface, I have a (hopefully) good user authentication, I
: have a DB up-and-running, and I have PHP 4.3.4 (yeah, I know, I will
: update...).
: What I need is a logging utility. And the question is: where to keep the
: logs?
: We (me and my buddy) have written everything from scratch (including
: sessions support) - in a quest to learn something useful. Now we need to
: decide where to keep our logs?
: We can either keep them in a DB (already running, so no
: setup/configuration needed here), or in a file.
: Obviously, the file has an advantage over the DB - no overhead, less
: queries. But here's the bad part: there will be ~500 users using this
: site. It most certainly *will* happen that a few will use it
: simultaneously.
: So, we can flock() the file. Great. I can see the queue getting dreadfuly
: long, the execution time getting dangerously near the limit and the
: users getting mad on the other side of the cable.
: Well, we don't have to flock() it. Fantastic - I can just imagine what
: will happen if ~10 instaces of the script will try to write to this file
: simultaneously. ..
Assuming you are on Linux or Unix.
Open the log file for append, and write entire lines at a time, no locking
is required (note _append_ mode, that's the key).
Up to a large size, (something like 64,000 bytes typical) each such line
is guaranteed to be written as a single atomic unit to the end of the
file, no locking required. This is a documented feature of append mode on
unix, and is done exactly for this kind of situation.
(In practise you rarely even have to write whole lines at a time, because
the program's file write will normally buffer your output and write it one
line at a time even if you don't do that part explicitly your self.)
This is true for linux/unix, but may not be true for windows.
--
This space not for rent.
On 2005-04-22, Malcolm Dew-Jones <yf***@vtn1.vic toria.tc.ca> wrote: Up to a large size, (something like 64,000 bytes typical) each such line is guaranteed to be written as a single atomic unit to the end of the file, no locking required. This is a documented feature of append mode on unix, and is done exactly for this kind of situation.
Where is this documented?
--
Cheers,
- Jacob Atzen
Jacob Atzen (ja***@aub.dk) wrote:
: On 2005-04-22, Malcolm Dew-Jones <yf***@vtn1.vic toria.tc.ca> wrote:
: > Up to a large size, (something like 64,000 bytes typical) each such
: > line is guaranteed to be written as a single atomic unit to the end of
: > the file, no locking required. This is a documented feature of append
: > mode on unix, and is done exactly for this kind of situation.
: Where is this documented?
I have no idea anymore where this is _directly_ stated, but here is one
example location in the linux man pages where this capability is _implied_
by mentioning an exception to it in NFS (from http://www.die.net/doc/linux/man/man2/open.2.html, found by a quick
google)
open(2) - Linux man page
NAME
open, creat - open and possibly create a file or device
SYNOPSIS
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
(snip)
O_APPEND
The file is opened in append mode. Before each write, the file
pointer is positioned at the end of the file, as if with lseek.
O_APPEND may lead to corrupted files on NFS file systems if more
than one process appends data to a file at once. This is because
NFS does not support appending to a file, so the client kernel has
to simulate it, which can't be done without a race condition.
Note the caveat that multi processing appending doesn't work properly on
NFS. They only mention this because it is an exception to the normal
state of affairs - where multi processing appending does not lead to
corrupted files.
I'm sure a unix or linux group would have someone who knows the document
where the exact details are mentioned.
--
This space not for rent.
One quick glance of an experienced eye allowed to understand the blurred
and almost unreadable Malcolm Dew-Jones's handwriting: Up to a large size, (something like 64,000 bytes typical) each such line is guaranteed to be written as a single atomic unit to the end of the file, no locking required. This is a documented feature of append mode on unix, and is done exactly for this kind of situation.
That would be great, if true. Doing a google search on this. :)
Thanks
Mike
Michal Wozniak wrote: Ok, I have a nice iface, I have a (hopefully) good user
authentication, I have a DB up-and-running, and I have PHP 4.3.4 (yeah, I know, I will update...).
What I need is a logging utility. And the question is: where to keep
the logs?
<snip>
What to log? Access?? If so, why not apache's log?
--
<?php echo 'Just another PHP saint'; ?>
Email: rrjanbiah-at-Y!com Blog: http://rajeshanbiah.blogspot.com/ This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Andrey Tatarinov |
last post by:
Hi.
It would be great to be able to reverse usage/definition parts in
haskell-way with "where" keyword. Since Python 3 would miss lambda, that
would be extremly useful for creating readable sources.
Usage could be something like:
>>> res = where:
>>> def f(x):
|
by: A.V.C. |
last post by:
Hello,
I found members of this group very helpful for my last queries.
Have one problem with CASE. I can use the column name alias in Order By Clause
but unable to use it in WHERE CLAUSE.
PLS TELL ME IF IT IS POSSIBLE TO USE IT IN WHERE CLAUSE AND SOME ALTERNATIVE.
QUERY:
SELECT
|
by: Xiangliang Meng |
last post by:
Hi, all.
In 1998, I graduated from Computer Science Dept. in a university in China.
Since then, I've been using C Language for almost 6 years. Although I'm
using C++ in my current job, I'm also interested in understanding C more and
deeper at the same time. In the past half year, I decide to improve myself
on C, read some books on C and digest some posts on comp.lang.c and
comp.lang.c++. Now, I feel I have a better insight on C than...
|
by: Britney |
last post by:
Original code:
this.oleDbSelectCommand1.CommandText = "SELECT TOP 100 user_id, password, nick_name, sex, age, has_picture, city, state, " +
"country FROM dbo.users WHERE (has_picture = ?) AND (sex = ?) ORDER BY age "
this.oleDbSelectCommand1.Parameters.Add(new System.Data.OleDb.OleDbParameter("has_picture", System.Data.OleDb.OleDbType.Boolean, 1, "has_picture"));
this.oleDbSelectCommand1.Parameters.Add(new...
|
by: comp.lang.php |
last post by:
if ($willLimitByDB) $sql = preg_replace('/#(+)#/i', '$$1',
$sql);
This does not give me the results I want, instead of the value of
$where in $sql, I literally get '$where' instead.
How do I substitute #where# with $where?
Thanx
Phil
| |
by: John |
last post by:
I just cannot manage to perform a SELECT query with NULL parameter...
My CATEGORY table does have one row where TCATEGORYPARENTID is null (real DB
null value).
TCATEGORYID and TCATEGORYPARENTID are uniqueidentifier columns.
My questions:
- is Type="Object", below, necessary?
- what shall I specify for DefaultValue in my function? I tried everything.
|
by: NeoPa |
last post by:
Background
Whenever code is used there must be a way to differentiate the actual code (which should be interpreted directly) with literal strings which should be interpreted as data. Numbers don't usually have this problem but Dates can too.
Debug.Print Me.ControlName
refers to a control on a form. Whereas,
Debug.Print "Me.ControlName"
simply prints the literal text
Me.ControlName
Where to Use Each Quote Type (' or ")
In some places...
|
by: not_a_commie |
last post by:
I was hoping for increased functionality with the where clause in C#
3.0. Using the new keyword 'var' would really allow us to take nice
advantage of these. Specifically:
1. I want to limit it to primitives: "where T : System.Type.Primitive"
or something like that.
2. I want to limit it to an unspecified generic: "where T : List<>".
3. I want to limit it to a generic with a subset of types: "where T :
List<new TTwhere TT : class" or...
|
by: Emin |
last post by:
Dear Experts,
I have a fairly simple query in which adding a where clause slows
things down by at least a factor of 100. The following is the slow
version of the query
-------------------------
SELECT * FROM
( Select x.event_date From x FULL OUTER JOIN y
ON x.event_date = y.event_date
|
by: chrisdavis |
last post by:
I'm trying to filter by query or put those values in a distinct query
in a where clause in some sort of list that it goes through but NOT at
the same time. Example:
ROW1
ROW2
ROW3
ROW4 , etc.
I want to go to the first row, do a WHERE statement, return the
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
| |
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |