1. What are the methods you use to solve traffic problems for large-volume websites?
First, verify that the server hardware is sufficient to support current traffic
Second, optimize database access.
Third, prohibit the external hotlinking.
Four, control the download of large files.
V. Use different hosts to divert the main traffic.
VI, use traffic analysis statistics software.
2. Write the code that displays the client IP and server IP in PHP:
Show Client IP
function Get_client_ip () {#
if (getenv (' http_client_ip ')) {
$client _ip = getenv (' http_client_ip ');
} elseif (getenv (' http_x_forwarded_for ')) {
$client _ip = getenv (' http_x_forwarded_for ');
} elseif (getenv (' remote_addr ')) {
$client _ip = getenv (' remote_addr ');
} else {
$client _ip = $HTTP _server_var[' remote_addr ');
}
return $client _ip;
}
Server IP
function Get_server_ip () {
if (Isset ($_server))
{
if ($_server[' server_addr ') $huoqu _ip=$_server[' server_addr '];
else $huoqu _ip=$_server[' local_addr '];
}
Else
{
$huoqu _ip=getenv (' server_addr ');
}
return $huoqu _ip;
}
3.MYsql Programming surface questions.
(1) In a content management system, the table message has the following fields:
ID Article ID
Title of title article
Content article contents
CATEGORY_ID article Category ID
Hits Click Volume
Create the table above and write out the MySQL statement:
CREATE TABLE ' message ' (
ID Int (one) not NULL auto_increment,
Title varchar (+) default NULL,
Content blob,
category_id Int (one) default NULL,
Hits int (one) default NULL,
PRIMARY KEY (' id ')
) Engine=innodb DEFAULT Charset=utf8;
(2) The same press release system: Table comment Record the user reply content, the fields are as follows:
comment_id Reply ID
ID article ID, ID in the associated message table
Comment_content Reply Content
Now by querying the database need to get the following format of the article title list, and according to the number of replies sorted, reply to the highest ranked in the front
Article ID article title click Reply Quantity
Use an SQL statement to complete the above query, if the article does not reply to the number of replies displayed as 0
SELECT message.id id,message.title title,if (message. ' Hits ' is Null,0,message. ' Hits ')
Hits,if (comment. ' id ' is null,0,count (*)) number
From message left JOIN comment on message.id=comment.id
GROUP by message. ' ID '
(3) The above Content management system, table category to save the classification information, the field is as follows (3 points)
category_id Int (4) not NULL auto_increment;
Categroy_name varchar (+) not null;
When a user enters an article, select the article category by selecting the drop-down menu
Write how to implement this drop-down menu
function CategoryList ()
{
$result =mysql_query ("Select Category_id,categroy_name from category")
Or Die ("Invalid query:".) Mysql_error ());
Print ("</select>");
}
Basic questions of PHP face questions