| Home | Articles | Archive | Links |


- Misc
ASP CGI And PHP Scripts And Record...
Are Cookies Evil What Service Do...
Are Free Domain Names Worth The Cost...
Are Paid Surveys For Real
Are Popins Better Than Banners Or...
Are Smileys Appropriate...
Are There Benefits To Ordering...
Are You A Savvy Online Shopper
Are You A Virtual Consultant
Are You Blogging Effectively
Are Your Subscribers Receiving Your...
Arm Yourself To Win The War Against...
Article Directories Information...
Article Sites
Article Directories Ranked By Alexa...
Article Marketing A Common Form...
Article Marketing Doesn t Work
Article Marketing Explained
Article Marketing Just Got Easier...
Article Marketing Myths And Facts
Article Marketing To Boost Site...
Article Plagiarism The Next Internet...
Article Submissions
Articles They Really Work
Attracting More People To Your Web...
- Design
Article Directory Website Design...
Article Directory Website Design...
- SEO
Are You Interested In Increasing...
Article Banks And Google Alerts...
Article Marketing For Search Engine...
Article Marketing How To Get Tons...
- Earning Money
Are Link Exchanges Harming Your...
Are You Setting Up A Website For...
Article Marketing How Articles Help...
Attracting Web Business
- Hosting
ASP Hosting Simplified
- Adsense
Are Made For Adsense Sites Ruining...
- Linking
Are Directory Links Still Effective...
Are Reciprocal Links Dead
- Auction
Are There Any Ebay Secrets That Are...
Auction Tips For Sellers And Bidders...

ASP CGI And PHP Scripts And Record Locking What Every Webmaster Needs To Know



M


any of us install                                                
server-side (ASP, CGI or       1. Follow-up autoresponders       
PHP) scripts on our web        typically store the list of       
sites, and many of this scripts       subscribers to the autoresponder, 
store data on the server.             as well where in the sequence of  
However, poorly designed scripts      messages, each subscriber is.     
can experience performance            Examples of autoresponder         
problems and sometimes even data      scripts:                          
corruption on busy (and not so        http://www.scriptcavern.com/scr_e 
busy) web sites.                      mail_auto.php                     
                                                                        
If you're not a programmer, why       2. Classified ad scripts store    
should this matter to you?            (at least) a list of all the      
                                      classified ads placed by          
Answer: Even if you're just           visitors. Examples of this type   
installing and using server-side      of script:                        
scripts, you'll want to make sure     http://www.scriptcavern.com/scr_c 
that the scripts that you choose      lassified.php                     
don't randomly break or corrupt                                         
your data.                            3. Free for all links scripts     
                                      store a list of all links posted  
First, some examples of the types     by visitors. See some example     
of scripts which store data on        scripts listed at:                
web servers include:                  http://www.scriptcavern.com/scr_f 
                                      fa.php                            
(Of course, many scripts in each                                        
of these (and other) categories       4. Top site scripts usually store 
are well-designed, and run            a list of the members of the top  
perfectly well even on very busy      site as well as information about 
web sites).                           the number of "votes" that each   



has received. For examples of         and does an update before the     
this type of script, see              first copy of the script has      
http://www.scriptcavern.com/scr_t     finished, a second copy of the    
opsite.php                            script starts running at the same 
                                      time.                             
So what kind of scripts have                                            
problems? And what sort of            3. There are a number of ways     
problems am I talking about?          things can now go wrong, for      
                                      example:                          
Well the principle problems all                                         
relate to what happens when bits      (a) What if the first copy of the 
of data from multiple users needs     script reads in the data, then    
to be stored on updated at the        the second copy reads the same    
same time. Some scripts handle        data, then the first copy updates 
these situations well, but others     the data, then the second copy    
don't...                              updates the data? Answer: any     
                                      changes made by the first copy of 
DATA CORRUPTION                       the script can get lost.          
                                                                        
Here's a common data corruption       (b) What if the first and second  
problem that can occur with many      copy of scripts are both adding   
scripts:                              multiple bits of new data to the  
                                      store at the same time? For       
1. When some bit of data needs to     example, imagine each needs to    
be updated, a copy of the             store the headline, description   
server-side script starts             and the name of the person        
running, and then starts updating     posting a classified ad. Well,    
it.                                   what can happen (with some        
                                      scripts) is the two classified    
2. If another user comes along        ads can get intermingled, so you  



might get (for example)               solution by itself (in            
HEADLINE-1, DESCRIPTION-1,            particular, a script which just   
HEADLINE-2, PERSON-1,                 does this could still have        
DESCRIPTION-2, PERSON-2. Or worse     problems if multiple copies of a  
yet, you might get bits of each       script update the same file at    
part of each classified ad, mixed     the same time), but it does make  
with the bits of the other. This      data corruption less likely, and  
type of thing is usually really       if corruption does occur, at      
bad news, as your data may            least it won't corrupt the entire 
consequently becoming unusable        data store in one go.             
from that point on.                                                     
                                      2. They can use file-locking.     
Does this sound too unlikely a        This means that if one copy of a  
problem to worry about? Don't         script is working with a file,    
bank on it... even if it happens      another copy of the script is     
only 1 time in 1,000, or 1 in         prevented from working on that    
10,000, eventually it will            file, until the first copy has    
happen: You need a solution.          finished. File-locking works if   
                                      done correctly, but programming   
So the real question is: is it        it into a script needs to be done 
possible for programmers to           very carefully and precisely, for 
create scripts without these          every single possible case...     
kinds of problems? Fortunately        even a tiny bug or omission can   
the answer is yes, and there are      allow the possibility of          
a number of ways that programmers     data-corruption in through the    
can address it:                       backdoor!                         
                                                                        
1. They can store each bit of         3. They can use a database (such  
data in a separate file. This         as MySQL) to store the data.      
isn't necessarily a total             Provided the data is properly     



structured in the database, the       (or all the links on your top     
database handles the locking          site, or all the subscribers to   
automatically. And, as the            your autoresponder, etc.).        
programmer doesn't have to write                                        
their own special locking             What would happen?                
routines, the possibility of bugs                                       
and omissions are much reduced.       Answer: Because each update can   
                                      only be performed after the       
PERFORMANCE PROBLEMS                  previous update has been          
                                      completely finished, your site    
Of course, avoiding having your       may be slow, or even unable to    
data corrupted should be the          handle all your users' requests.  
paramount consideration in                                              
choosing a script, but is there       So what's the solution?           
anything else we need to be                                             
concerned about?                      There's two options that          
                                      programmers can use:              
Answer: Performance                                                     
                                      1. They can use lots of small     
Of course, all webmasters are         files and file-lock each          
aiming to build busy high traffic     individually (for example, one    
web sites... but will your            per classified, one per top site  
scripts be able to handle the         listing, etc.). Of course, this   
load?                                 needs to be handled very          
                                      carefully...                      
Go back and re-read the paragraph                                       
on file-locking. Now think about      2. They can use a database (like  
what would happen if all the          MySQL), as databases allow any    
classified ads on your classified     one individual record ("row") to  
page were stored in a single file     be updated, even when another is  



also being updated.                                                     
                                      And one additional point:         
IN CONCLUSION                                                           
                                      3. Even the best script is not    
Now, let's summarise:                 immune to hard-disk hardware      
                                      failures, your web host being     
1. Scripts that store data in         struck by lightning, and all the  
files need to use file-locking to     other snafus that can happen. So, 
avoid data-corruption, and they       do take regular back-ups of any   
also need to break the data into      data that you can't afford to     
separately updateable chunks to       lose!                             
avoid performance problems on                                           
busy web sites.                       In short, even if you're not a    
                                      script programmer, you need to be 
2. Scripts that store data in         aware of data storage issues. In  
databases (like MySQL), provided      future, when considering a script 
of course that they have been         for your web site, don't be       
properly coded, are usually less      afraid to ask some hard questions 
likely to suffer from                 about how it stores data and how  
data-corruption or performance        well it handles multiple users.   
problems.                             

                              






About the Author:

This article was written by Sunil Tanna of Answers 2000. For a directory of ASP, CGI, PHP and Remotely hosted scripts, please visit http://www.scriptcavern.com - and for scripts written by Answers 2000 please visit http://www.scriptrocket.com


Read more articles by: Sunil Tanna

Article Source: www.iSnare.com


...Archive >>

Submit Your Site
Recent Articles
  • Reseller Hosting Business : Getting Started

    Starting a reseller web hosting business can be a dream project for expanding your hands over the internet website market but one thing you shall keep clear in mind that decisions you make shall not be taken overnight or in the manner of fastest procedures Any time you start a new reseller web hosting business you shall be clear with a few of the important things which are necessary to keep clear before you opt web hosting as a reseller business for your bread making purposes which we are going to clear in this article The first thing you need to clear is marketing plans and research work for the same in the manner that what shall be your web hosting package configuration and what shall be your market spending areas like for advertising purposes, seo services and others as after all there shall be a proper planning in case you are looking towards long life term business hopes with this new era of web hosting reseller business for your professional life as without a proper planning for both packages and marketing you cannot do the business more than a few days or a month while it shall be not your hopes to do this business for small term...

  • CPanel Web Hosting : Advantages and Benefits

    Are you going to host a new website or planning to move your web hosting provider then remember to choose the one which offer you cPanel web hosting CPanel is one of the most popular control panels for Linux web hosting accounts and today its usages are on boom which is making it more and more popular It is enriched with a tons of features and benefits along with abilities of fantastico sort of website builder engines and good news is this that today most of the internet web hosting service provider today offer cPanel as a web hosting control panel with their Linux web hosting offers...

    Copyright (c) 2008 Isnare.com. All rights reserved.

  • Google
    ASP CGI And PHP Scripts And Record Locking What Every Webmaster Needs To Know