PDA

توجه ! این یک نسخه آرشیو شده میباشد و در این حالت شما عکسی را مشاهده نمیکنید برای مشاهده کامل متن و عکسها بر روی لینک مقابل کلیک کنید : Taking a load off: Load balancing with balance



MelatHOST
December 25th, 2009, 23:09
A server is limited in how many users it can serve in a given period of time, and once it hits that limit, the only options are to replace it with a newer, faster machine, or add another server and share the load between them. A load balancer can distribute connections among two or more servers, proportionally cutting the work each has to do. Load balancing can help with almost any kind of service, including HTTP, DNS, FTP, POP/IMAP, and SMTP. There are a number of open source load balancing applications, but one simple command-line load balancer, balance, remains one of the most popular available.

Ideally you should install a load balancer on a dedicated machine that can handle all the incoming connections, with a separate network interface for internal and external connections. However, none of this is necessary for the purposes of this article. To start testing balance, download the latest version from the project's Web site. Unpack it, build it, and install it as follows:

# tar -zxvf balance-3.24.tar.gz
# cd balance-3.24
# ./configure
# make
# make install

Keep in mind that you'll need to be running as root in order to access ports below 1024.

Let's start with a simple case. We have connections coming in to port 80, the default HTTP port. We'd like to evenly share the work between two computers (although load may be distributed among any number). You specify machines to balance by referencing their IP addresses or hostnames. By default balance will connect to those machines on the same port on which it is listening. You can specify other ports by adding ":port" to the end of the address.

Let's assume we have two machines with hostnames "alpha" and beta". The most basic solution (we'll get to more sophisticated uses in a moment) is just to alternate connections between the two computers, back and forth. This kind of balancing is called round-robin. It simply means each person or device gets an equal share, one after the other.

Balance has a simple command-line interface. We need to tell it where incoming connections will be coming from, and the possible destinations. By running:

# balance -f 80 alpha beta

we can share the load equally between servers alpha and beta. Including the -f parameter will keep balance in the foreground. Without it, balance will fork to the background, but an adminstrator could communicate with it interactively by running balance -i. In this example, if the machines alpha and beta machines happen to be serving different data and you were the only current user, refreshing the page over and over would alternate you between the two sites (although presumably in most cases you would want both computers to serve the same content).

Another thing we can do with balance is set a failover machine. That is, if for some reason a connection fails or times out, balance will establish a connection to the failover. For example, the command:

# balance -f 80 alpha beta ! failover

tells balance to forward a connection to the machine named failover only if both alpha and beta fail. The exclamation point separates the machines into two separate groups. Connections will only be forwarded to the next group if all connections to the first fail.

Another way of telling balance to move to the next group is by setting a limit on the number of connections a machine can handle, as follows:

# balance -f 80 alpha::256 ! beta::64 ! failover

This specifies that alpha can handle up to 256 simultaneous connections, after which point balance will move on to beta, and once beta has 64 connections, we finally move to the failover machine. The basic idea here is that we're filling up one virtual bucket before we move on to the next.

There's one important thing still lacking with these kinds of balancing commands. While sufficient for static HTML content, many real-world Web sites require sessions. User logins, shopping carts, or any kind of "memory" from page to page require session data to be retained when a user clicks onto a different page. Because HTTP is inherently stateless, each time we load a new page we're starting a new connection, which the load balancer might well send to a new machine. This would make preserving session information difficult.

The easiest solution to this problem is to make sure each client always gets forwarded to the same machine. We can tell balance to do this with the command:

# balance -f 80 alpha beta %

The percent symbol denotes that the preceding group will be a "hash" type. Balance will hash the user's IP address and associate it with one of the machines. As long as the IP address remains the same, a connection initiated from it will always go to the same computer. A good hashing algorithm will make sure hashes are evenly spread among the machines.

Where do we go from here?

These techniques will produce a good, workable load balancer, but in cases where load is great, they will not suffice. An application like the Linux Virtual Server is more appropriate for cases like this. The LVS works on the IP level to increase efficiency, in contrast to balance, which works on the application level and thus has increased overhead in that it must deal with the HTTP protocol. In addition, LVS provides many different kinds of scheduling in addition to round-robin and hashing, which are the only methods we can use in the free version of balance. But the basic principles remain the same.

Thanks to load balancing, you can keep your servers' connection and download times high, and seamlessly serve the ever-increasing number of clients using the Internet every day.

arak-hosting
December 25th, 2009, 23:16
دوستان با گوگل ترجمه کردم ولی جیزی خودم نفهمیدم :71:

======================================

سرور که بسیاری از کاربران در چگونگی آن می تواند در مدت زمان داده شده از زمان در خدمت محدود است ، و پس از آن که بازدید را محدود کند ، فقط به گزینه های آن را با جدیدتر ، ماشین سریعتر ، و یا دیگر سرور ها و تقسیم بار بین آنها را تعویض کرد. متعادل کننده بار می تواند ارتباط میان دو یا چند سرویس دهنده توزیع ، متناسب برش هر یک به کار انجام دهد. توازن بار را می توان با تقریبا هر نوع از خدمات ، از جمله HTTP ، دی ان اس ، FTP ، پاپ / IMAP کمک کند و SMTP. تعدادی از بار متعادل کردن برنامه های کاربردی متن باز است ، اما یکی از ساده خط فرمان متعادل کننده بار ، تعادل ، همچنان وجود دارد یکی از محبوب ترین موجود است.

ایده آل شما باید یک بار متعادل کننده را روی یک کامپیوتر اختصاص داده شده است که می تواند کلیه اتصالات ورودی اداره نصب ، با یک رابط شبکه مجزا برای اتصالات داخلی و خارجی. با این حال ، هیچ یک از این برای اهداف این مقاله ضروری است. برای شروع آزمایش تعادل ، دریافت آخرین نسخه از سایت پروژه وب سایت. باز کردن آن ، آن را ساخت ، و نصب آن را به عنوان شرح زیر است :

# tar -zxvf balance-3.24.tar.gz
# cd balance-3.24
# ./configure
# make
# make install

به خاطر داشته باشید که شما باید در حال اجرا به عنوان ریشه به منظور دسترسی به پورت های زیر 1024.

شروع میکنم با یک مورد ساده است. در حال حاضر در ارتباط آینده به پورت 80 ، پورت پیشفرض. ما می خواهم به کار بین دو کامپیوتر طور مساوی سهم (هر چند بار ممکن است در میان هر عدد توزیع شود). ماشین های مشخص شده توسط شما را به تعادل خود را مرجع یا آدرس آی. hostnames. با تعادل پیش فرض برای آن دستگاه بر روی پورت مشابه در آن است گوش متصل شود. شما می توانید با اضافه کردن پورت های دیگر ": بندر" را به پایان آدرس مشخص کنید.

بیایید فرض کنیم که دو ماشین با hostnames "آلفا" و بتا ". در این راه حل ابتدایی ترین (خواهیم به پیچیدهتر استفاده میکند در یک لحظه گرفتن) فقط جهت اتصال متناوب بین دو کامپیوتر ، به عقب و جلو. این نوع توازن نامیده می شود گرد سینه سرخ از آن به سادگی به معنای هر فرد یا دستگاه میشود سهم برابر ، یکی پس از دیگری.

تعادل تا به ساده رابط خط فرمان. ما نیاز به آن را بگویید که در آن اتصالات ورودی خواهد بود از آمدن و مقصد ممکن است. با اجرای :


# balance -f 80 alpha beta

ما می توانیم بار به طور مساوی بین سرورها تقسیم آلفا و بتا می باشد. از جمله پارامتر - f خواهد شد تعادل در عرصهی نگه می دارد. و بدون آن ، تعادل برای پس زمینه چنگال ، اما مدیر می تواند با آن ارتباط برقرار تعاملی توازن در حال اجرا توسط - Ï. در این مثال ، اگر دستگاه ها و ماشین های آلفا بتا می شود رخ می دهد داده های مختلف و خدمت به شما کاربر تنها فعلی بودند ، طراوت صفحه و بیش از بیش را جایگزین شما بین دو سایت (هرچند که احتمالا در اکثر موارد شما را به هر دو رایانه می خواهید در خدمت محتوا همان).

چیز دیگری که ما می توانیم با تعادل انجام شده است مجموعه ای دستگاه failover. این معنا که اگر به دلایلی با شکست مواجه و یا اتصال بار کردن ، تعادل به اتصال به failover برقرار. به عنوان مثال ، دستور :

# balance -f 80 alpha beta ! failover

می گوید تعادل به جلو اتصال به دستگاه به نام failover تنها اگر هر دو آلفا و بتا شکست منجر میشود. علامت تعجب هم جدا ماشین آلات به دو گروه جداگانه. اتصالات تنها برای گروه بعدی هدایت میشوید اگر تمام اتصالات به اولین شکست منجر میشود.

یکی دیگر از راه گفتن به تعادل حرکت را به گروه بعدی می باشد با تنظیم محدودیتی در تعداد اتصال دستگاه قادر به هندل ، عبارتند از :


# balance -f 80 alpha::256 ! beta::64 ! failover

این مشخص است که می تواند دسته آلفا تا 256 ارتباط همزمان ، و بعد از آن نقطه تعادل را در حرکت به بتا ، بتا و یک بار تا 64 اتصالات ، ما در نهایت به دستگاه failover حرکت می کند. ایده اساسی در اینجا این است که ما در حال پر کردن یک سطل مجازی قبل از ما در به بعدی حرکت کند.

یکی چیزی مهم هنوز بدون با این نوع دستورات توازن وجود دارد. کافی در حالی که برای محتوای متنی استاتیک ، بسیاری از دنیای واقعی وب سایت نیاز به جلسه است. کاربر logins ، چرخ دستی خرید ، و یا هر نوع از "حافظه" را از صفحه به صفحه نیاز به جلسه داده شود که نگه داشته کلیک کاربر بر روی یک صفحه متفاوت است. از آنجا که HTTP ذاتا بی وطن ، هر بار یک صفحه جدید با شروع می کنیم اتصال جدید ، که ممکن است به خوبی متعادل کننده بار به دستگاه جدید بفرستید ما بار. این امر باعث حفاظت از اطلاعات جلسه دشوار است.

ساده ترین راه حل این مشکل این است تا مطمئن شویم که هر یک از مشتری همیشه به همان دستگاه فرستاده میشود. ما می توانیم تعادل را به انجام این کار را با دستور ارسال :

# balance -f 80 alpha beta %

درصد نشاندهنده نماد که گروه قبل خواهد شد فیلم "" را تایپ کنید. تعادل خواهد شد آدرس کاربر مالکیت معنوی و دیپلم آن را با یکی از دستگاه های هش. تا زمانی که نشانی پروتکل باقی مانده است همان ، ارتباط آغاز از آن همواره به همان کامپیوتر بروید. خوب الگوریتم هش کردن مطمئن خواهند شد که هش طور مساوی در میان دستگاه های پخش شده است.

باید از کجا بگیریم از اینجا برود؟

در این تکنیکها خواهد شد خوب ، اعمال متعادل کننده بار ، تولید ، اما در مواردی که بار بزرگ شده است می کنند ، آنها کفایت خواهد کرد. برنامه کاربردی مانند لینوکس مجازی سرور مناسب برای موارد مثل این. LVS آثار در سطح آی برای افزایش بهره وری ، در مقابل برای حفظ تعادل ، که آثار در سطح نرم افزار و در نتیجه تا به بالای سر است که در آن باید با پروتکل HTTP قرارداد افزایش یافته است. علاوه بر این ، LVS فراهم می کند انواع مختلفی از برنامه ریزی علاوه بر گرد سینه سرخ و هش کردن ، که تنها روشهای ما می توانیم در نسخه رایگان از تعادل استفاده کنید. اما اصول اساسی باقی می ماند همان.

با تشکر از بار حفظ تعادل ، شما می توانید اتصال سرورهای خود را و بار دانلود بالا ، حفظ و خدمت به seamlessly همواره تعداد بیشتری از مشتریان با استفاده از اینترنت هر روز.

MelatHOST
December 25th, 2009, 23:22
سلام
این آموزش load balancing سرور هستش
شما میتونید دو تا سرور داشته باشید و از دو eth برای یک سرور استفاده کنید تا در زمان پیک تایم (اوج مصرف ) یا دیداس
eth دوم هم به اولی اضافه میشه
همچنین httpd , dns , sql رو هم میتونید بالانس کنید
http://www.inlab.de/balance-3.24.tar.gz
tar -zxvf balance-3.24.tar.gz
# cd balance-3.24
# ./configure
# make
# make install

---------- Post added at 11:22 PM ---------- Previous post was at 11:19 PM ----------


BALANCE(1) BALANCE(1)
NAME
balance 3.24 − A simple TCP proxy with load balancing and failover mechanisms.
SYNOPSIS
balance [ -b addr ] [ -B addr ] [ -t sec ] [ -T sec ] [ -dfpH ] por t host1[:por t1[:maxc]] [!|%] [ ...
hostn[:por tn[:maxc]]]
balance [ -b addr ] -i [ -d ] por t
balance [ -b addr ] -c cmd [ -d ] por t
DESCRIPTION
Balance is a simple, gener ic "user land" TCP proxy, which allows simple round robin load balancing
and failover between serveral destinations.
Balance is available at Inlab Software GmbH - Balance (http://balance.sourceforge.net).
Definitions: A possible destination consisting of a host address and a port is called a "channel". A
channel is member of a "channel group". Channels are numbered in a group starting with 0,
groups are also numbered starting with 0, which is the initial default group.
Balance accepts connections on the given port and forwards them to the supplied channels. At
least one channel (in the default group) must be specified. If there are two or more channels
specified in a group balance perfor ms a simple round robin load balancing between these channels.
Balance allows the definition of further channel groups. The connection scheme here wor ks as
follows: balance tr ies first to establish a connection to a channel in the first group (0) perfor ming
the standard round robin load balancing scheme. If no channel in this group is available, balance
proceeds the same way with the next higher channel group. Groups are simply separated with a
"!" at the command line at startup and can be controlled interactively with the "group" command.
A "%" instead of a "!" as a group separator declares the previous group to be of type "hash". This
means, that instead of a round robin algorithm a hash distribution based on the client ip address
is used to determine the destination channel. This allows connecting one client always to the
same server, which allows e.g. balancing http sessions.
Hosts may be specified either by its name or by its ip address. Por ts may be specified either
alphanumer ically (as in /etc/services) or numer ically. If there’s no por t specified in a destination
the destination port defaults to the source port that balance controls.
Balance allows the specification of the maximum number of connections per channel. This
parameter can be optionally added after the port specification separated by a colon (":"). If a maximum
number of connections is specified a channel will only be used for this maximum number of
simultaneous connections. A maxc value of 0 denotes an unlimited number of connections. This
is the initial default value of a channel.
The maximum number of groups and channels balance can handle is specified at compile time
and is initially 16 channels in 16 groups.
Failover to another destination (a "channel") occurs if the connection is refused on the current
channel or if the connect timeout is reached trying to establish a connection. If all possible destinations
(channels) currently fail, the initial connection to balance itself is closed immediately.
Balance accepts the following options:
b Bindhost: Balance binds to the specified host (or address) for listen() instead to
INADDR_ANY.
B Bindhost: Balance binds to the specified host (or address) for outgoing connections (the
connection will be initiated from this address).
c Command: allows to send a command to the balance master process (see interactive
mode)
2005/06/04 1
BALANCE(1) BALANCE(1)
d Debug: Balance outputs debugging and tracing infor mation messages on stderr.
H Hashfailover: Balance does failover to next node even if hash is used.
F Foreground: tells balance to stay in foreground. This might be useful for testing and
debugging since balance can be stopped in that mode using ˆC (or other interrupt character).
i Interactive Control: Balance connects to the running instance defined by local port and
bind address via shared memory and allows to control the behaviour of it using a command
line interface. The access permission using this interface are determined by the
access restrictions of the shared memory segment in effect. help or ? pr ints out a short
command overview, create allows to establish a new destination definition (channel) consisting
of host and port in the current group, disable disables a channel in the current
group, enable enables a channel again in the current group, group changes the current
group in interactive mode where all following commands are targeted, hash changes the
current group to be of type "Hash", help pr ints out online help infor mations, kill shuts
down the master process and exits interactive mode, maxc <channel> <maxc> sets the
maximum number of connection ot the channel (0 means infinite), quit exits the interactive
mode, reset resets the byte counters of a channel, rr changes the current group to
be of type "Round Robin", show shows an overview and the status of all channels including
the incoming and outgoing transfer volume in bytes. The output is sorted by groups.
Additionally the current connections (c) and the maximum allowed connections (maxc)
are printed, version pr ints out the version and MAXGROUPS and MAXCHANNELS constants
at compile time.
p Packetdump: Balance shows all incoming and outgoing data on stdout using a simple
always readable exter nal representation of data. This might be useful for debugging and
protocol analysis.
t Connect Timeout: the default timeout trying to establish a connection to any destination
can be changed using this option. The default timeout after which a destination is
regarded to be currently inaccessible is 5 seconds.
T Select Timeout: Timeout for select(), default = 0 (never). This feature is currently
untested.
EXAMPLES
$ balance smtp host1.test.net host2.test.net
Connection to the local SMTP port will be forwarded alterating to the SMTP port on host1
and host2. Balance runs automatically in background.
$ balance -fp imap mailserver
Connections to the local IMAP port will always be forwarded to the host "mailserver". Balance
stays in foreground and all data is printed in readable for mat on stdout.
$ balance -f 8888 host1 10.1.1.1:8000
Connections to the local port 8888 are forwarded alternating to host1, port 8888 and the
host 10.1.1.1, port 8000. Balance stays in foreground connected to the "controlling tty".
$ balance imap mailserver1::16 ! mailserver2
Two groups are specified, each containing one channel member. First up to 16 simultaneous
connections are forwarded to "mailserver1". As soon as they are consumed, balance
proceeds with the next group (1) which will consume all remaining connections forwarding
them to the imap ort on "mailser ver2".
$ balance pop3 host1 host2 host3 ! failover1
Balance does round robin load balancing for the three hosts in the default group 0 for
pop3 services. If all three hosts in group 0 fail, all connections are then forwarded to the
2005/06/04 2
BALANCE(1) BALANCE(1)
host "failover1".
$ balance telnet target.munich.net::1
Here balance is used to restrict all connections to exactly one at a time forwarding the telnet
port.
$ balance 8888 localhost::12 ! localhost::4 ! localhost::2 localhost::2 ! localhost:25
This is a simple test, for ming 5 groups where balance is self referencing its own services
20 times. This is simply a test which definitely can be tried at home.
BUGS
In case that balance is not able to forward the connection to any destination the inital connection
to balance is always first accepted and then closed again immediately. This is not in every case
the behaviour that would have been seen directly on the destination host.
AUTHOR
Thomas Obermair, Inlab Software GmbH (obermair@acm.org)
Copyr ight (c) 2000-2004,2005 by Thomas Obermair (obermair@acm.org) and Inlab Software
GmbH (Inlab Software GmbH - Home (http://www.inlab.de)), Gruenwald, Germany. All rights reserved.
Balance is released under the GNU GENERAL PUBLIC LICENSE, see the file COPYING in the
source code distribution.[COLOR="Silver"]

WebRang
December 25th, 2009, 23:25
ممنون سعید جان، خودت تست کردی؟!

MelatHOST
December 26th, 2009, 00:13
خواهش میکنم
من فقط واسه vpn تست کردم