You are on page 1of 67

Load Balance Web Server

A Case Study use Load Balance on Web Server


Chotima Channukul

2552

..

Load Balance Web Server



5117620009

2552
. .



. .





II

1
1.1
1.2
1.3
1.4
1.5
1.6
1.7
1.8
2
2.1 Load Balance
- 2.1.1 Round Robin DNS
- 2.2.2 Random Redirection
- 2.2.3 Load Balancer
2.2 Cluster Computing
- 2.2.1
- 2.2.2
- 2.2.3 Cluster Computing
- 2.2.4
2.3 World Wide Web : HTTP
- 2.3.1 HTTP
- 2.3.2 (HTTP Message)
- 2.3.3 HTTP Response Message

l
II
III
lV
VII
1
1
2
2
2
2
2
3
3
4
4
4
5
5
7
7
8
8
9
10
11
11
12

III

()

2.4
- 2.4.1
- 2.4.2
2.5
- 2.5.1 A Scalable HTTP Server: The NCSA Prototype
- 2.5.2 Scalable Web Server Architectures
- 2.5.3 Network Dispatcher: a Connection Router for Scalable
Internet Services
- 2.5.4 High Performance Web-Server Systems
- 2.5.5 Redirection Algorithms for Load Sharing in Distributed
Web-Server Systems
- 2.5.6 Dynamic Load Balancing on Web-Server Systems
- 2.5.7 Load Balancing a Cluster of Web Servers Using
Distributed Packet Rewriting
- 2.5.8 Load Distribution via Static Scheduling and Client Redirection
for Replicated Web Servers
- 2.5.9 Locality-Aware Request Distribution in Web Server Clusters
- 2.5.10 Efficient Support for Content-based Routing in
Web Server Clusters
- 2.5.11 Scalable Content-aware Request Distribution in
Cluster-based Network Servers
- 2.5.12 Summary Cache
- 2.5.13 Cache Digests [1]
- 2.5.14 An Adaptive Load Balancing Algorithm
Using Simple Prediction

12
12
13
13
13
13
13
13
14
14
14
14
15
15
15
15
16
16

IV

()

3
3.1
- 3.1.1
3.2 3
- 3.2.1 1 Scrip Load Balance
- 3.2.2 2 Application Scan Streaming
- 3.2.3 3 Database
3.3
3.4
- 3.4.1
- 3.4.2

17
17
17
18
18
19
20
20
21
21
30

4
4.1
4.2
4.3
5
5.1
5.2
5.3

41
41
44
46
47
47
48
48
49
51
52

4.1 Load Balance


Server 2
4.2 Load Balance
Server 3
4.3 Load Balance
Server 2
4.4 Load Balance
Server 3

45
45
46
46

VI

2.1 Round Robin DNS


2.2 Random Redirection
2.3 Load Balance
2.4 HTTP
3.1
3.2 Flow Chart Scrip Load Balance
3.3 Flow Chart Application Scan Streaming
3.4 Flow Chart Database
4.1
4.2
4.3
4.4 Scan Streaming
4.5 netstat n
4.6

4
5
6
10
17
18
19
20
41
42
42
42
43
44

VII

1
Load Balance Web server
1.1

Google


Router load balancing





1.
2.
3.
4.

5. load Balance

1.2



1.
Load Balancer
Server Request User Request
Load Balancer Forward Request Server


1.3
1. Load Balance

2.
3.
1.4
1. Load Balance Web Server
2.

3. Server 3
4.
5.

1.5
1.
2.
3. Load Balancing
4.
5.
6.
7.
1.6
1. Load Balancing
2.
3.
4.
1.7
5
1

2
3
4
5

1.8


2552/1
.

1.

2.
3.
4.

5.

2552/2
. .

1.

2.
3.
4.

5.

2.
2.1 Load Balance
2.1.1 Round Robin DNS Feature DNS register domain
ip address

Round Robin load
real-time register server load
mapping dns cache

2.1 Round Robin DNS

2.2.2 Random Redirection

User

User

User

Distribute

User

User

Server1

User

Server2

2.2 Random Redirection


1 user Distribute Server Redirect User
Server user www.narisa.com browser request
user Distribute Distribute Server
redirect user www1.narisa.com www2.narisa.com
internet Load
Balancer ( 7-8 Load Balancer
1,000,000 )
2.2.3 Load Balancer Load Balancer
Server Request User Request Load
Balancer Forward Request Server CODE

2.3 Load Balance

1. Register DNS IP Load Balancer www.narisa.com --->


xxx.xxx.xxx.1
2. Load Balancer Profile Profile profile Narisa.com
3. Register IP Address Server Profile Load
Balancer profile Narisa.com Server1 ip xxx.xxx.xxx.2 Server2
ip xxx.xxx.xxx.3
4. User Request www.narisa.com request
load balancer load balancer Profile Policy load
balance Round Robin Performance Sticky
Forward Request User Server 3 4
VIP Virtual IP IP xxx.xxx.xxx.1 IP
IP Load Balancer IP Server1 Server2 IP
Load Balancer Hardware Software
Load Balancer Hardware
Software

Load Balance 3 Single Point of Failure


Load Balancer User 3
6

Backup Load Balancer


Load Balancer down
0.001 Backup
2.2 Cluster Computing




, ,


2.2.1 2




www ftp

(Node)
Front-end Node
Compute Node
Network
Information System (NIS) (User)
(Login)
,
, (Parallel
Computing)

2.2.2 (Installation Clustering System)


( ,
) (Linux,
Solaris, BSD) (Linux) Distribution
RedHat, Debian, Turbo Linux, Slackware

(Message Passing)


PVM
Oak Rige National Laboratory University of Tennessee at Knoxville
.. 1994 MPI
PVM
Utility Library
Library Math Scalapack, PetSc
Graphic Rendering
(Render)
2.2.3 Cluster Computing
Cluster Computing Lan (Local Area Networking)
Cluster Computing 3

Lan LAN


Cluster Computing Grid (Grid Computing)
Cluster Computing
(Platform) Grid
Computing
Cluster Computing Load balancing
Cluster Computing

Clustering
(Replication) Web Application Session Replication
Session Web Server Clustering
8

Replicate Session Web Server


Server Session Load
Balancing Load

Fail Over

Load Balancer
Load Load

Cluster Feature Server Develop
Application Cluster Feature Server
File Sharing Database Load Balance
Hardware Software Load Balancer
Application Traffic Server
Redirection
(Parallel Processing)



2.2.4
Custer Computing 1
1 (CPU)
CPU, ROM, RAM


Feature Load
Balance Clustering
(Personal Computer : PC)


Beowulf Cluster

PC

PC Cluster
Software (Linux)
(Open Source) , MPI
(Message Passing Interface) PVM (Parallel Virtual Machine)

2.3 World Wide Web : HTTP


(World Wide Web) (Web) WWW
WWW HTTP
(Hyper Text Transfer Protocol) HTML (Hyper Text Markup
Language) HTML WWW
WWW
(Web Server) HTML
(Web Browser)
(IE) HTML

TP
HT

s
Re

T
HT

e
ns
po

es
qu
e
R

Internet

2.4 HTTP

10

2.3.1 HTTP
HTTP
TCP/IP ()

2.1
URL (Uniform Resource Locator)
(Address) (HTTP
Request)
URL (HTTP Response)

HTTP

2.3.2 (HTTP Message)
HTTP 1.1 (HTTP/1.1)

(HTTP Request Messags)
(HTTP Response Message)
- HTTP Request Message

GET / somedir/page.html HTTP/1.0


Host : www.gitew.co.th
Connection: close
User-agent : Mazilla/4.0
(extra carriage return, line feed)

ASCll Text 4
CR/LF (Carriage Return and Line Feed)
CR/LE
(Header)

3 (Method)
URL HTTP
GET URL
HEAD

11

HTML POST


Host : www.gitex.co.th
URL www.gitex.co.th
User Agent: Mozilla/4.0

2.3.3 HTTP Response Message

HTTP/1.1 200 OK
Connection : close
Date : Thu, 06 Aug 2003 12:00:15 GMT
Server : Apache/2.0.4 (Unix)
Last-Modified: Mon , 22 Jun 2003 09:23:24 GMT
Content-Length : 6821
Content-Type : text/html
(data data data data data.)
3
(Status Line) 6
3
HTTP
HTTP 1.1

2.4
2.4.1
Static Load Distribution

Dynamic Load Distribution

Adaptive Load Distribution


12

2.4.2
Location Policy
State Polling Information Policy

Transfer Policy
2.5
2.5.1 A Scalable HTTP Server: The NCSA Prototype



(Round Robin)
2.5.2 Scalable Web Server Architectures





HTTP Redirect
2.5.3 Network Dispatcher: a Connection Router for Scalable Internet
Services
(Router)

IP Packet Forwarding
2.5.4 High Performance Web-Server Systems

Mirror Sites

13

2.5.5 Redirection Algorithms for Load Sharing in Distributed Web-Server


Systems




2.5.6 Dynamic Load Balancing on Web-Server Systems



Client-based, DNS-based, Dispatcher-based,
Server-based
2.5.7 Load Balancing a Cluster of Web Servers Using Distributed Packet
Rewriting



Distributed Packet Rewriting
2.5.8 Load Distribution via Static Scheduling and Client Redirection for
Replicated Web Servers









14

2.5.9 Locality-Aware Request Distribution in Web Server Clusters


(Front End)







2.5.10 Efficient Support for Content-based Routing in Web Server Clusters





(Dynamic Content)

2.5.11 Scalable Content-aware Request Distribution in Cluster-based
Network Servers

Layer 4
Switch



2.5.12 Summary Cache

(Summary Cache)



15

2.5.13 Cache Digests [1]


(Cache Digests)

2.5.14 An Adaptive Load Balancing Algorithm Using Simple Prediction





16

3

3.1

nd

Re

qu

es

Count

192.168.1.2

192.168.1.3

192.168.1.4

Se
nd

Re
qu
e

st

Se

IP

nd
Se

t
da

Se
n

da
ta

3.1
3.1.1
Client Web Server Scrip Load Balance
redirect Server Database
Server 1, 2, n Real Time

3.2 3
3.2.1 1 Scrip Load Balance Web Server Load Balance
Database
Client Server

Start

Client

Scrip Load
Balance

Database

Server 1
(ip address 1)

Server N
(ip address N)

3.2 Flow Chart Scrip Load Balance

18

3.2.2 2 Application Scan Streaming Server 1, 2,..

Client Net Stat n


Net Stat n ip port Client
Database

Start

Get

netstat -n

ip address
port 80
Client

Count

Database

3.3 Flow Chart Application Scan Streaming

19

3.2.3 3 Database
2 ip Server 1, 2, n
Client

3.4 Flow Chart Database


3.3
Load Balance
Server 1,2,n Server Private Server 1 Private Server 2
Server
Round Robin DNS Feature DNS Register Domain
ip address Private Server
Client Client Web Server IP 192.168.1.1
Web Server Client Index Web server Load Balance
Private Server 1,2 ,n
Private Server

20

3.4


2 IIS Server
XP SQL Server 2005
3.4.1
XP
IIS
1. Start > Settings > Control Panel
2. Add or Remove Programs
3. Add/Remove Windows Components

4. Internet Information Services (IIS)


Details...

21

5. Next>
6. Windows XP OK Browse CD
Windows XP i386

22

23

7. Open, OK
8. IIS

24

9. Finish

IIS
1. My Computer > Manage

25

2. Services and Applications > Internet Information Services > Web Sites >
Default Web Site

3. Default Web Site > Properties


4. Web Site
Description : www.cmsthailand.com
IP Address : IP Address ( IP
All Unassigned)
TCP Port : 80
port 80 http://192.168.1.5 (
http://192.168.1.5:80)
81
http://192.168.1.5:81

26

5. Home Directory
Local Path : <drive:\>Inetpub\wwwroot
[ ] Script source access :
[ / ] Read :
[ ] Write :
[ ] Directory browsing :
[ / ] Log visits :
[ / ] Index this resource : index

27

Configuration...

28

6. Document
Home Page Add
index.html > HTML
index.shtml > SHTML
index.asp > ASP
index.aspx > ASP.NET

ASP index.html, index.asp

29

7. OK
8. Stop Start IIS 1

9. IIS
3.4.2
SQL Server 2005
1. SQL Server 2005 SQLEXPR_ADV
SQLEXPR_ADV

30

2. > Next

3. Install

31

4. Next

5. Next

32

6. Next

7. check box Hide advanced configuration options


> Next

33

8. Tool Patch
Database Database Services

9. Next

34

10. Named instance SQL2005 ( Default instance


Named instance)

Default instance Default Computer Connect Database


Master
Server Name = Master
Named instance Computer\
Server Name = Master\SQL2005
11. Next

35

12. Use the bult-in System account > Network service Local
System > Next

13. Mixed Mode (Windows Autentication and SQL Server Authentication) >
Password
Enter password : ( password sa )
Confirm password : ( password sa )
14. Next

36

15. Next

16. Next

37

17. Next

18. Next

38

19. Install

20. Next

39

21. Finish

22. OK

40

Web Server
4.1

1 Scrip Load Balance Web Server DNS
Register IP Client 4.1 Private
Server Server Server
Private Server
4.2 4.3 Private Server

4.1

41

4.2

4.3
2 Scan Streaming Private Server IP Address
Port

2
3
4
5

4.4 Scan Streaming

42

1 IP Server Server IP Address


2 Server IP Address

3
4 Username
5 Password
6
Save
Start
Change
IP Address port 80 Server
netstat n 4.5 Server IP 192.168.1.3 port 80 IP
192.168.1.20 Server IP 192.168.1.3 4.6

4.5 netstat -n

43

4.6
4.2
Load Balance 2
- Client
- Private Server

44

/

4.1 Load Balance Server 2

( )
IP
1
2
3
4
5
6
7
8
9
10
Private
Server
192.168.1.2
/
/
/
/
/
/
/
/
/
/
192.168.1.3

4.2 Load Balance Server 3



( )
IP
1
2
3
4
5
6
7
8
9
10
Private
Server
192.168.1.2
/
/
/
/
/
/
/
/
/
/
192.168.1.3

192.168.1.4

45

4.3 Load Balance Server 2


( )
IP
Private
2
3
4
5
6
Server
192.168.1.2
/
/
/
/
/
192.168.1.3

4.4 Load Balance Server 2


( )
IP
Private
2
3
4
5
6
Server
x
x
192.168.1.2
/
/
/
192.168.1.3

192.168.1.4

4.3
Load Balance
Client 20 Private Server 2 Load Balance
Load
Balance

46

5.1
Round Robin DNS
session
Private Server
CPU RAM Private Server

1.
2.
3.
4.
5.
6.

Private Server
Load Balance

1. CPU RAM Private Server


2.

3.
4. Private Server
Browser

5.2
Web Server Windows XP
VB.net Server VMware

Computer, Switch, LAN Card


5.3
5.2.1
CPU RAM Server
5.2.2 Load Balance
Web Server Google Load Balance
Bandwidth Internet Caf
5.2.3 Load Balance

5.2.4 Load Balance


Load Load

5.2.5 Load Balance
Router, Switch Layer 3, Firewall Load Balance

48

[1]

[2]

[3]

[4]
[5]

[6]

[7]

[8]

Alex Rousskov and Duane Wessels. Cache Digests. Proceedings of the 3rd
International WWW Caching Workshop, Manchester, England , June 1998.
TERENA, Trans-European Research and Education Networking
Association.
Antoine Mourad and Huiqun Liu. Scalable Web Server Architectures.
Proceedings of the IEEE Symposium on Computers and Communications
(ISCC97),Alexandria, Egypt, July 1997.
Chu Sing Yang and MonYen Luo. Efficient Support for ContentBased
Routing in Web Server Clusters. USENIX Symposium on Internet
Technologies and Systems, Boulder, Colorado, USA, October 1999.
Eric Dean Katz, Michelle Butler and Robert McGrath. A Scalable HTTP Server:
The NCSA Prototype. Computer Networks and ISDN Systems, 1994.
Gil-Haeng Lee, Wang-Don Woo and Byeong-Nam Yoon. An Adaptive Load
Balancing Algorithm Using Simple Prediction Mechanism. Proceedings of
th
the 9 International Database and Expert Systems Applications Workshop,
496-501, 1998.
Guerney D.H. Hunt, German S. Goldszmidt, Richard P. King and Rajat
Mukherjee. Network Dispatcher: a connection router for scalable Internet
th
services. Proceedings of the 7 International World Wide Web Conference,
Brisbane, Australia, April 1998.
Li Fan, Pei Cao, Jussara Almeida and Andrei Z. Border. Summary Cache: A
Scalable Wide-Area Web Cache Sharing Protocol. IEEE/ACM
Transactions on Networking, 8(3):281-293, June 2000.
Luis Aversa and Azer Bestavros. Load Balancing a Cluster of Web Servers Using
Distributed Packet Rewriting. Proceedings of the IEEE International
Performance, Computing, and Communications Conference, Phoenix, AZ
USA, February 2000.
49

[9]

[10]

[11]

[12]

[13]

[14]

[15]
[16]
[17]

Mohit Aron et al, Darren Sanders, Peter Druschel and Willy Zwaenepoel.
Scalable ContentAware Request Distribution in Clusterbased Network
Servers. Proceedings of the 2000 USENIX Annual Technical Conference,
SanDiego, CA USA, June 2000.
Valeria Cardellini, Michele Colajanni and Philip S. Yu. Dynamic Load
Balancing on Web-Server Systems. IEEE Internet Computing, 3(3):28-39,
May-June 1999.
Valeria Cardellini, Michele Colajanni and Philip S. Yu. Redirection Algorithms
for Load Sharing in Distributed Web-Server Systems. Proceedings of the
th
19 International Conference on Distributed Computing Systems, Austin,
Texas, June 1999.
Vivek S. Pai, Mohit Aron, Gauray Banga, Michael Svendsen, Peter Druschel,
Willy Zwaenepoel and Erich Nahum. LocalityAware Request
th
Distribution in Clusterbased Network Servers. Proceedings of the 8
ACM Conference on Architectural Support for Programming Languages
and Operating Systems, Sanjose, CA USA, October 1998.
Valeria Cardellini, Michele Colajanni and Philip S. Yu. High Performance Webth
server Systems. Proceedings of the 13 International Symposium on
Computer and Information Sciences, Ankara, Turkey, October 1998.
Wenting Tang and Matt W. Mutka. Load Distribution via Static Scheduling and
client Redirection for Replicated Web Servers. Proceedings of the
International Workshop on Scalable Web Services (in conjunction with
ICPP00), Toronto, Ontario, Canada, August 2000.
Alteon Personal Content Director [Online]. Available from :
http://www.westcon.uk/alteon/alteonprodinfoPCD.htm [2001, Sep 17]
Network Simulation2 [Online]. Available from : http://www.isi.edu/nsnam/ns
[2002, Jan 10]
Yahoo [Online]. Available from : http://www.yahoo.com [2001, Aug 14]

50



1.
1.1 Code Connection database
Public Class clsManageSQL
Private conn As SqlConnection
Private comm As SqlCommand
Private tr As SqlTransaction
Private strcon As String = "Data Source=" &
ConfigurationManager.AppSettings("HOST") & ";User ID=" &
ConfigurationManager.AppSettings("Username") & ";PWD=" &
ConfigurationManager.AppSettings("Password") & ";initial catalog=" &
ConfigurationManager.AppSettings("DatabaseName") & ";Max Pool
Size=2000;Connect Timeout=600"
Public Function Open() As Boolean
Try
conn = New SqlConnection
comm = New SqlCommand
With conn
If .State = ConnectionState.Open Then .Close()
.ConnectionString = strcon
.Open()
Return True
End With
Catch ex As Exception
Throw New Exception("{clsManageSQL.open}" & ex.Message & "
" & Now)
Return False
End Try
End Function
Public Sub Dispose()
conn.Close()
conn.Dispose()
comm.Dispose()
End Sub
Public Function ExecuteDataHaving(ByVal sql As String) As Boolean
Try
Dim rd As SqlDataReader
comm.CommandType = CommandType.Text
comm.CommandText = sql
comm.Connection = conn
rd = comm.ExecuteReader()
If rd.Read Then

52

rd.Close()
Return True
Else
rd.Close()
Return False
End If
Catch ex As Exception
Throw New Exception("ExecuteDataHaving" & ex.Message)
Finally
End Try
End Function
Public Sub ExecuteNonQuery(ByVal sql As String)
Try
comm.Connection = conn
tr = conn.BeginTransaction
comm.Transaction = tr
comm.CommandType = CommandType.Text
comm.CommandText = sql
comm.ExecuteNonQuery()
tr.Commit()
Catch ex As Exception
' Throw New Exception("clsManageSql Error:
{ExecuteNonQuery}-" & ex.Message)
tr.Rollback()
End Try
End Sub
Public Function ExecuteDataTable(ByVal sql As String) As DataTable
Dim da As SqlDataAdapter
Dim ds As New DataSet
conn = New SqlConnection
comm = New SqlCommand
With conn
If .State = ConnectionState.Open Then .Close()
.ConnectionString = strcon
.Open()
End With
da = New SqlDataAdapter(sql, strcon)
da.Fill(ds, "table")
Return ds.Tables(0).Copy()
End Function
Public Function getMaxID(ByVal tableName As String, ByVal fdIdxName
As String) As Integer
Try
Dim sql As String
Open()
Dim rd As SqlDataReader

53

sql = "select max(" & fdIdxName & ")as maxID from " &
tableName
comm.CommandType = CommandType.Text
comm.CommandText = sql
comm.Connection = conn
rd = comm.ExecuteReader()
If rd.Read Then
Return CInt(rd("maxID")) + 1
Else
Return 1
End If

Catch ex As Exception
Return 1
Finally
Dispose()
End Try
End Function
End Class

1.2 Code Redirect


Imports System.Data
Partial Class _Default
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Load
Redirect()
End Sub

Private Sub Redirect()


Dim conn As New clsManageSQL
Dim sql As String
Dim dt As datatable
sql = "SELECT
TOP (1) ip "
sql += "FROM tb_ip "
sql += "WHERE count_total ="
sql += " (SELECT MIN(count_total) AS tot"
sql += " FROM tb_ip AS tb_ip_1)"
conn.Open()
dt = conn.ExecuteDataTable(sql)
Dim ip As String = dt.Rows(0)("ip")
Response.Redirect("http://" & ip & "/index.aspx")
conn.Dispose()
End Sub

54

End Class

2. Code ScanStreaming
Public Class Form1
Dim timing As Integer = 0
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Me.tbIP_SERVER.Text = My.Settings.IP_SERVER
Me.tbDB_HOST.Text = My.Settings.DBHost
Me.tb_DB_NAME.Text = My.Settings.DBName
Me.TB_USER.Text = My.Settings.DBUsername
Me.TB_PASS.Text = My.Settings.DBPassword
Me.tbTimer.Text = My.Settings.TIMER

End Sub

Private Function scan() As ArrayList


Try
Dim output As String
Dim line As String
Dim proc As New Process()
proc.StartInfo.CreateNoWindow = True
proc.StartInfo.FileName = "netstat"
proc.StartInfo.Arguments = "-n"
proc.StartInfo.RedirectStandardOutput = True
proc.StartInfo.UseShellExecute = False
proc.Start()
output = proc.StandardOutput.ReadToEnd()

proc.WaitForExit()
Dim arr As New ArrayList
Dim sr As New StringReader(output.ToString())
'
line = Nothing
Dim lineRead As String
Dim str As String = ""

Do While (True)
Dim strTmp As String

lineRead = sr.ReadLine

55

Dim tmp As String


Dim pos As Integer
pos = InStr(lineRead, My.Settings.IP_SERVER & ":80")

If pos > 0 Then


tmp = Mid(lineRead, 32, 25)
Dim arrTmp1() As String
arrTmp1 = tmp.Split(":")

str = arrTmp1(0).Trim
If arr.Count > 0 Then
For i As Integer = 0 To arr.Count - 1
If arr(i) = str.Trim Then
Exit For
Else
If i = arr.Count - 1 And arr(i) <>
str.Trim Then
arr.Add(str.Trim)
End If
End If
Next
Else
arr.Add(str.Trim)
End If
End If

If (lineRead Is Nothing) Then


Return arr
Exit Do
End If
Loop
' MsgBox(str)
'
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Function

Private Sub Process()

Try

Dim arr As New ArrayList

56

arr = scan()
If arr.Count > 0 Then
updateDB(arr.Count)
Else
updateDB(0)
End If
Catch ex As Exception
' MsgBox(ex.Message)
End Try
End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Button1.Click

Me.Timer1.Enabled = True
End Sub

Private Sub updateDB(ByVal count As Integer)


Try
Dim conn As New clsManageSQL
Dim sql As String = "update tb_ip set count_total = " &
count
sql += " where ip = '" & My.Settings.IP_SERVER & "'"
conn.Open()
conn.ExecuteNonQuery(sql)
conn.Dispose()

Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Button2.Click
Try
My.Settings.IP_SERVER = Me.tbIP_SERVER.Text.Trim
My.Settings.DBHost = Me.tbDB_HOST.Text
My.Settings.DBName = Me.tb_DB_NAME.Text
My.Settings.DBUsername = Me.TB_USER.Text
My.Settings.DBPassword = Me.TB_PASS.Text
My.Settings.TIMER = Me.tbTimer.Text
My.Settings.Save()
Me.tbIP_SERVER.ReadOnly = True

57

Me.tbDB_HOST.ReadOnly = True
Me.tb_DB_NAME.ReadOnly = True
Me.TB_USER.ReadOnly = True
Me.TB_PASS.ReadOnly = True
Me.tbTimer.ReadOnly = True
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button3.Click
Try
Me.tbIP_SERVER.ReadOnly = False

Me.tbIP_SERVER.ReadOnly = False
Me.tbDB_HOST.ReadOnly = False
Me.tb_DB_NAME.ReadOnly = False
Me.TB_USER.ReadOnly = False
Me.TB_PASS.ReadOnly = False
Me.tbTimer.ReadOnly = False

Catch ex As Exception
End Try

End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Timer1.Tick
Try
If timing = My.Settings.TIMER Then
Me.lbStatus.Text = "Done."
timing = 0
Process()
Else
Me.lbStatus.Text = "Process"
timing += 1
End If

Catch ex As Exception
MsgBox(ex.Message)
End Try

58

End Sub
End Class

59

You might also like