2 web servers serving same pages

2 web servers serving same pages

am 09.04.2008 21:40:59 von plenty900

Hi folks,

If 2 copies of Apache are serving the same pages and
running the same PHP, what if anything could get
messed up? I am specifically thinking session
variables might, but I know I don't know... so anybody know?

Thanks.

Re: 2 web servers serving same pages

am 09.04.2008 22:34:00 von unknown

Post removed (X-No-Archive: yes)

Re: 2 web servers serving same pages

am 09.04.2008 23:10:38 von plenty900

> This is not recommended unless the PHP does not modifications to the
> pages or a database. Unless you put logic in the php code to check for
> simultaneous access, you're libel to get weird and unpredictable results
> of the two servers attempt to modify the same thing at the same time.

My impression is that every SQL access would have to be
surrounded by LOCK TABLES and UNLOCK TABLES commands.

But regarding sessions, it occurs to me that if a user
does one access and it goes to server A, and the next
access goes to server B, each server could have different
session info for that user.

Re: 2 web servers serving same pages

am 09.04.2008 23:39:17 von Jerry Stuckle

plenty900@yahoo.com wrote:
>> This is not recommended unless the PHP does not modifications to the
>> pages or a database. Unless you put logic in the php code to check for
>> simultaneous access, you're libel to get weird and unpredictable results
>> of the two servers attempt to modify the same thing at the same time.
>
> My impression is that every SQL access would have to be
> surrounded by LOCK TABLES and UNLOCK TABLES commands.
>
> But regarding sessions, it occurs to me that if a user
> does one access and it goes to server A, and the next
> access goes to server B, each server could have different
> session info for that user.
>
>

The RDBMS will handle the updates just fine. It's absolutely no
different than if you have two different people on the same website
updating the database at the same time.

The same with sessions. Although it's theoretically possible for two
sessions to get the same id, the odds are greatly against it. You'd
have a better chance of winning the lottery.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

Re: 2 web servers serving same pages

am 09.04.2008 23:41:52 von Jerry Stuckle

plenty900@yahoo.com wrote:
>> This is not recommended unless the PHP does not modifications to the
>> pages or a database. Unless you put logic in the php code to check for
>> simultaneous access, you're libel to get weird and unpredictable results
>> of the two servers attempt to modify the same thing at the same time.
>
> My impression is that every SQL access would have to be
> surrounded by LOCK TABLES and UNLOCK TABLES commands.
>
> But regarding sessions, it occurs to me that if a user
> does one access and it goes to server A, and the next
> access goes to server B, each server could have different
> session info for that user.
>
>

Hit the button too fast...

What you do have to watch out for is changes to the file system other
than through the SQL database. This can get you into more trouble - but
again, you need to be careful anyway, even in a single server
environment. But you are more likely to have problems in this area than
anywhere else.

Just follow good multitasking programming practices and you should be ok.


--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

Re: 2 web servers serving same pages

am 09.04.2008 23:44:24 von Courtney

Michael Vilain wrote:
> In article
> ,
> plenty900@yahoo.com wrote:
>
>> Hi folks,
>>
>> If 2 copies of Apache are serving the same pages and
>> running the same PHP, what if anything could get
>> messed up? I am specifically thinking session
>> variables might, but I know I don't know... so anybody know?
>>
>> Thanks.
>
> This is not recommended unless the PHP does not modifications to the
> pages or a database. Unless you put logic in the php code to check for
> simultaneous access, you're libel to get weird and unpredictable results
> of the two servers attempt to modify the same thing at the same time.
>

They cant really can they?

any more than two pages on the same server can do it.

As long as its only ONE database they both access.

Every web page served or posted is an atomic php script anyway. whether
its off one or two servers makes zero difference.


> This setup is also a kludge and you should rethink it. It's usually not
> a good idea to have two things trying to get at the same thing.

Whtya? like tow users both acessing our databse from two sessions on one
server.

Shit. All my code must have broken years ago ;-)

> Occasionally you'll have a problem--think male/female room mates (not
> sex partners). How do you coordinate who gets the bathroom in the
> morning?
>
Who cares. As long as its read only access. If two people want to crap
in the same toilet, theres a short element of [hysical impossibility,
same as two servers acessing an SQL database. Each insert or update is
an atomic unit dealt with on a serial basis, and the Mysql deamon will
simply block one until the previous has completed.

Only the case where a read/modify/update cyle is going on requires a
lock setting: But how often will two people be modifying the SAME record?

Almost never in a public database: users will only be allowed to update
their data. its the DB admins who update the generic stuff.That's where
locks are needed. Irrespective of how many apache servers are driving
the database.

There is almost no difference between having one server with multiple
instances of itself and two servers with multiple instances of themselves.

What you can't do is have two SQL daemons accessing the same file
structures..

Re: 2 web servers serving same pages

am 10.04.2008 01:08:56 von unknown

Post removed (X-No-Archive: yes)

Re: 2 web servers serving same pages

am 10.04.2008 01:11:04 von unknown

Post removed (X-No-Archive: yes)

Re: 2 web servers serving same pages

am 10.04.2008 02:04:53 von unknown

Post removed (X-No-Archive: yes)

Re: 2 web servers serving same pages

am 10.04.2008 02:05:32 von unknown

Post removed (X-No-Archive: yes)

Re: 2 web servers serving same pages

am 10.04.2008 04:42:03 von unknown

Post removed (X-No-Archive: yes)

Re: 2 web servers serving same pages

am 10.04.2008 04:53:33 von unknown

Post removed (X-No-Archive: yes)

Re: 2 web servers serving same pages

am 10.04.2008 05:07:07 von Jerry Stuckle

Michael Vilain wrote:
> In article
> <2da27430-370a-48ea-8a3d-f0ad51a098c0@x41g2000hsb.googlegroups.com>,
> plenty900@yahoo.com wrote:
>
>>> This is not recommended unless the PHP does not modifications to the
>>> pages or a database. Unless you put logic in the php code to check for
>>> simultaneous access, you're libel to get weird and unpredictable results
>>> of the two servers attempt to modify the same thing at the same time.
>> My impression is that every SQL access would have to be
>> surrounded by LOCK TABLES and UNLOCK TABLES commands.
>>
>> But regarding sessions, it occurs to me that if a user
>> does one access and it goes to server A, and the next
>> access goes to server B, each server could have different
>> session info for that user.
>
> The OP didn't say they were using a database, so SQL isn't involved.
>

LOCK TABLES and UNLOCK TABLES are SQL statements...

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

Re: 2 web servers serving same pages

am 10.04.2008 05:10:23 von Jerry Stuckle

The Natural Philosopher wrote:
> Michael Vilain wrote:
>> In article
>> ,
>> plenty900@yahoo.com wrote:
>>
>>> Hi folks,
>>>
>>> If 2 copies of Apache are serving the same pages and
>>> running the same PHP, what if anything could get
>>> messed up? I am specifically thinking session
>>> variables might, but I know I don't know... so anybody know?
>>>
>>> Thanks.
>>
>> This is not recommended unless the PHP does not modifications to the
>> pages or a database. Unless you put logic in the php code to check
>> for simultaneous access, you're libel to get weird and unpredictable
>> results of the two servers attempt to modify the same thing at the
>> same time.
>>
>
> They cant really can they?
>
> any more than two pages on the same server can do it.
>
> As long as its only ONE database they both access.
>
> Every web page served or posted is an atomic php script anyway. whether
> its off one or two servers makes zero difference.
>

PHP scripts are NOT atomic!

>
>> This setup is also a kludge and you should rethink it. It's usually
>> not a good idea to have two things trying to get at the same thing.
>
> Whtya? like tow users both acessing our databse from two sessions on one
> server.
>
> Shit. All my code must have broken years ago ;-)
>
>> Occasionally you'll have a problem--think male/female room mates (not
>> sex partners). How do you coordinate who gets the bathroom in the
>> morning?
>>
> Who cares. As long as its read only access. If two people want to crap
> in the same toilet, theres a short element of [hysical impossibility,
> same as two servers acessing an SQL database. Each insert or update is
> an atomic unit dealt with on a serial basis, and the Mysql deamon will
> simply block one until the previous has completed.
>
> Only the case where a read/modify/update cyle is going on requires a
> lock setting: But how often will two people be modifying the SAME record?
>
> Almost never in a public database: users will only be allowed to update
> their data. its the DB admins who update the generic stuff.That's where
> locks are needed. Irrespective of how many apache servers are driving
> the database.
>

It depends on the database and the access. I've had a lot of cases over
the years where this could be a BIG problem. But for typical web pages,
it's not a problem.

> There is almost no difference between having one server with multiple
> instances of itself and two servers with multiple instances of themselves.
>
> What you can't do is have two SQL daemons accessing the same file
> structures..
>
>
>
>


--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================