Update Application value on multiple servers?

A

Art

Can I update Application("SomeVariableName") on server A in response to user's action on server B? There is no problem in updating the same variable on server B, of course, but we would like both variables to be in sync since users can view the value stored on arbitrary server.

So far I have tried server.execute and server.transer to execute script updating Application("SomeVariableName") value on server A in response to user's action on server B but these methods didn't work - documentation conformed it.

Is there another, perhaps some creative way of doing it?
 
T

Tom Kaminski [MVP]

Art said:
Can I update Application("SomeVariableName") on server A in response to
user's action on server B? There is no problem in updating the same variable
on server B, of course, but we would like both variables to be in sync since
users can view the value stored on arbitrary server.
So far I have tried server.execute and server.transer to execute script
updating Application("SomeVariableName") value on server A in response to
user's action on server B but these methods didn't work - documentation
conformed it.
Is there another, perhaps some creative way of doing it?

Store the value in a database.

--
Tom Kaminski IIS MVP
http://www.microsoft.com/windowsserver2003/community/centers/iis/
http://mvp.support.microsoft.com/
http://www.iisfaq.com/
http://www.iistoolshed.com/ - tools, scripts, and utilities for running IIS
http://www.tryiis.com
 
A

Aaron [SQL Server MVP]

Maybe you misunderstood Tom's point. You would only hit the DB when
application_onstart is fired, e.g. in Global.asa:

Sub Application_OnStart()
Set conn = CreateObject("ADODB.Connection")
conn.open "<connection string>"
set rs = conn.execute("SELECT ConstantValue FROM Constants WHERE
ConstantName = 'foo'")
application("foo") = rs(0)
rs.close: set rs = nothing
conn.close: set conn = nothing
End Sub

--
http://www.aspfaq.com/
(Reverse address to reply.)
 
M

Mark Schupp

I think he wants to update he app var dynamically through an asp page on one
server and not require an app restart.

I would suggest putting the new value into a db for when the app does
restart and then using ServerXMLHTTP to hit an update page on the other
server to either change the app var directly or reload all the vars from the
db.

--
Mark Schupp
Head of Development
Integrity eLearning
www.ielearning.com
 
A

Aaron [SQL Server MVP]

Then I don't understand why it can't be in a database. It's not like
hitting a database is going to add noticeable response time to the page,
unless you're using Access and it's connected to your web server via the
floppy drive on a remote PC logged into a VPN over dial-up...
 
R

Ray at

Aaron said:
It's not like
hitting a database is going to add noticeable response time to the page,
unless you're using Access and it's connected to your web server via the
floppy drive on a remote PC logged into a VPN over dial-up...

This is going on my wall of quotes, as soon as I get around to having one.

Ray at home
 
A

Aaron [SQL Server MVP]

very expensive to get (no indexes, full table scans

Why are you using poor database design as an excuse for poor application
design? Fix the database!
But the problem again is - how do you make sure that Application variable
storing this reference count gets updated throughout all the servers in a
web farm?

I still don't understand the problem. If you update the database and keep
whatever reference count you're talking about in a database, there is no
need to synchronize between all the servers in the farm. It belongs in a
central place for exactly this reason!
 
B

Bob Barrows [MVP]

Art said:
If this was up to me then yes, fixing database is the proper course
of action. It is, however, something I'm not going to discuss as an
option here since, like I said, I don't control it.


Well, that's what we have right now:) On average it takes 2-3 seconds
to execute this query (to get the count) + anything else that a page
might be doing. More often than not that particular query is the
bottleneck in our application. This is done once per page.
We suggested that perhaps we could cache the value and requery DB for
an upated one at some interval but users said NO - they want to see
accurate count.
Next thought - let's use Application variable, query for the count at
application's start up and then whenever user performs an action
which updates the count we just add the code to up the Application
variable's value. That's trivial to implement and maintain. The value
of this information is also trivial since it's just a count for
informative purposes - so it's not like we are going to lose a sale
because the count might be off by one (which it would not be anyway).
We are trying to shave off 2 seconds per page here! Of course,
database needs to be fixed but you have no control over it and you
need to come up w/ competetive and/or alternative idea to speed that
up - do you have one?

Since you have a web farm, you can't use an Application variable. The count
needs to be stored centrally. How about caching it in a separate table in
your database? You could use triggers to maintain the value.

Or are you unable to even add a new table to your database?

Bob Barrows
 
M

Mark Schupp

I have to agree with Aaron and Bob on this one even though I originally
suggested using a post from the affected server to the others. What if an
action that would change the count takes place one 2 servers
"simultaneously"?

Build the count on app startup and put it in a separate "reference count"
table as Bob suggests. Then perform your updates to that table until the
next app restart.

--
Mark Schupp
Head of Development
Integrity eLearning
www.ielearning.com


Art said:
If this was up to me then yes, fixing database is the proper course of
action. It is, however, something I'm not going to discuss as an option here
since, like I said, I don't control it.
Well, that's what we have right now:) On average it takes 2-3 seconds to
execute this query (to get the count) + anything else that a page might be
doing. More often than not that particular query is the bottleneck in our
application. This is done once per page.
We suggested that perhaps we could cache the value and requery DB for an
upated one at some interval but users said NO - they want to see accurate
count.
Next thought - let's use Application variable, query for the count at
application's start up and then whenever user performs an action which
updates the count we just add the code to up the Application variable's
value. That's trivial to implement and maintain. The value of this
information is also trivial since it's just a count for informative
purposes - so it's not like we are going to lose a sale because the count
might be off by one (which it would not be anyway).
We are trying to shave off 2 seconds per page here! Of course, database
needs to be fixed but you have no control over it and you need to come up w/
competetive and/or alternative idea to speed that up - do you have one?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Staff online

Members online

Forum statistics

Threads
474,159
Messages
2,570,879
Members
47,414
Latest member
GayleWedel

Latest Threads

Top