[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Updating *HEAVILY* Accessed HTML Web Page

Posted on 1997-12-30
5
Medium Priority
?
259 Views
Last Modified: 2013-12-25
I am planning on having hundred of thousands of hits on my web site; I am certain my web pages will be heavily accessed.

A problem I'm facing is the "hourly" updates to the web pages; Updates can be a one liner to the entire HTML page. My Hourly Bot uses a .BAK file of the present web page to create the NEW web page named: WEB_PAGE.tmp. Then it sits in a WHILE loop waiting for the RENAME function to rename (move) the WEB_PAGE.TMP file to the visible (what the client sees) WEB_PAGE.HTML.
ie:
                    while(!(rename("web_page.tmp","web_page.html"))
{sleep(3);}

Once the RENAME has succeeded, any new accesses to
WEB_PAGE.HTML will be faced with the NEW page. Great! But, if I have hundreds of thousands of users to the old page, the above WHILE loop will be in there forever!

Is there another way to somehow HALT/PAUSE the clients for a split seconds to copy over the old HTML file with the NEW one?? Or is my above method the best, most efficient way?!

Maybe I should pass all calls on my site to a CGI script which uses the status 302 LOCATION command to redirect the client to the proper page. This way, if the Hourly Bot posts a STOP SIGNAL this CGI script can take notice and "pause/halt" any new calls to an HTML page.

Please, any suggestions which can help me out of this dilema would be GREATLY APPRECIATED!
0
Comment
Question by:ljaques
5 Comments
 
LVL 5

Expert Comment

by:icd
ID: 1831780
I wish I knew how to get hundreds of thousands of users to my web site every day!

Seriously though. How about serving the page from a script, or ssi. The script could then test for the presence of the hourly bot trying to do a rename and serve the user an alternative page leaving the original file un-accessed and able to do a rename.

I suspect however that even with many concurrent accesses to that file there are going to be many windows of opportunity for the hourly bot to do a rename. If the file is so heavily used that there is *no* window then the server will not be coping very well with the load anyway. Your approach would seem to be workable.

0
 
LVL 85

Expert Comment

by:ozo
ID: 1831781
Why is the rename failing?
0
 
LVL 1

Expert Comment

by:nanullnet
ID: 1831782
see similar question in perl area
0
 
LVL 1

Accepted Solution

by:
nanullnet earned 200 total points
ID: 1831783
You do not need to worry about a user accessing an html page while you are updating it. The web server handles the order it services requests. So simply write the new file and rename it. The user serviced right before will get the old page, the user next in line will get the new page when you are done.  

0
 

Author Comment

by:ljaques
ID: 1831784
So, renaming a my new .BAK file over the old HTM file is ok?
The server actions what Nanullnet mentions sounds a lot like a "stack".  If this is the case what if there's hundreds of thousands of users already on the stack before me.  I'd hate for the process to take forever.

If the "rename" is placed on the server stack then will my WHILE loop method return back immediately or does it sit in the loop forvere until the server gets to my request in its stack??

Tanx everyone.  Happy new Year!
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I hope you'll find this tutorial useful and interesting. So let's try to extend Tcl with a new package.  For anyone more deeply interested please check out the book "Practical Programming in Tcl and Tk". It's really one of the best written books abo…
In threads here at EE, each comment has a unique Identifier (ID). It is easy to get the full path for an ID via the right-click context menu. However, we often want to post a short link within a thread rather than the full link. This article shows a…
Learn the basics of if, else, and elif statements in Python 2.7. Use "if" statements to test a specified condition.: The structure of an if statement is as follows: (CODE) Use "else" statements to allow the execution of an alternative, if the …
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
Suggested Courses

873 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question