Received: from makus.postgresql.org (makus.postgresql.org [98.129.198.125]) by mail.postgresql.org (Postfix) with ESMTP id 8BDC2184B5AC for ; Wed, 30 May 2012 14:12:42 -0300 (ADT) Received: from mx2.d2.com ([66.251.81.121]) by makus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1SZmRr-00015Y-If for pgsql-admin@postgresql.org; Wed, 30 May 2012 17:12:42 +0000 Received: from mxb.d2.com ([10.85.4.6]) by mx2.d2.com (8.13.8/8.13.8) with ESMTP id q4UI8gm4004169 for ; Wed, 30 May 2012 11:08:42 -0700 X-ASG-Debug-ID: 1338397937-01d10a6c961cd0cc0001-ysJW5H Received: from mail01.d2.com ([172.16.66.171]) by mxb.d2.com with ESMTP id 1UyFMjPq5hoV18IO for ; Wed, 30 May 2012 10:12:17 -0700 (PDT) X-Barracuda-Envelope-From: aalvarez@d2.com Received: from exbew2k3-02.d2.com (exbew2k3-02 [10.78.2.16]) by mail01.d2.com (8.13.8/8.13.8/Debian-3) with ESMTP id q4UHCH63017223 for ; Wed, 30 May 2012 10:12:17 -0700 Received: from [10.126.2.220] ([10.126.2.220] RDNS failed) by exbew2k3-02.d2.com with Microsoft SMTPSVC(6.0.3790.3959); Wed, 30 May 2012 10:12:17 -0700 Message-ID: <4FC654F1.7000809@d2.com> Date: Wed, 30 May 2012 10:12:17 -0700 From: Amador Alvarez User-Agent: Mozilla/5.0 (X11; U; Linux i686 (x86_64); en-US; rv:1.9.2.27) Gecko/20120216 Lightning/1.0b2 Thunderbird/3.1.19 MIME-Version: 1.0 To: pgsql-admin@postgresql.org Subject: Re: Data split -- Creating a copy of database without outage References: <000901cd3dd7$8654a690$92fdf3b0$@gmail.com> <00b101cd3e76$d9f04e40$8dd0eac0$@gmail.com> X-ASG-Orig-Subj: Re: [ADMIN] Data split -- Creating a copy of database without outage In-Reply-To: <00b101cd3e76$d9f04e40$8dd0eac0$@gmail.com> Content-Type: multipart/alternative; boundary="------------090100090600090105020703" X-OriginalArrivalTime: 30 May 2012 17:12:17.0270 (UTC) FILETIME=[5D6F6160:01CD3E87] X-Barracuda-Connect: UNKNOWN[172.16.66.171] X-Barracuda-Start-Time: 1338397937 X-Barracuda-URL: http://10.85.4.6:8000/cgi-mod/mark.cgi X-Virus-Scanned: by bsmtpd at d2.com X-Barracuda-Spam-Score: 0.00 X-Barracuda-Spam-Status: No, SCORE=0.00 using per-user scores of TAG_LEVEL=1000.0 QUARANTINE_LEVEL=1000.0 KILL_LEVEL=9.0 tests=HTML_MESSAGE X-Barracuda-Spam-Report: Code version 3.2, rules version 3.2.2.98455 Rule breakdown below pts rule name description ---- ---------------------- -------------------------------------------------- 0.00 HTML_MESSAGE BODY: HTML included in message X-Spam-Status: NO, score=-2.4 required=3.0 tests=ALL_TRUSTED,AWL,BAYES_00, HTML_MESSAGE, HTML_TITLE_EMPTY, RATWARE_GECKO_BUILD autolearn=ham version=3.2.4 X-Spam-Checker-Version: SpamAssassin 3.2.4 (2008-01-01) on mx2.d2.com X-Pg-Spam-Score: -1.9 (-) X-Archive-Number: 201205/101 X-Sequence-Number: 39590 This is a multi-part message in MIME format. --------------090100090600090105020703 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Hi , I would start with a single high performance tuned database focusing mainly on dealing efficiently with concurrent activity and identifying the real hot spots. If you check out that you really need to go forward on database power, consider on adding new databases and relocate some users whenever you need it. Take a look on the different options related to replication, tunning and database balancers, set up some testings and get a deeper understanding on your real needs and performance. A.A. On 05/30/2012 08:14 AM, Igor Shmain wrote: > > Thank you, Liu, for your suggestion. > > I might be missing something (I am new to postgres), but it seems that > your suggestion will not help much in my case. Since the number of db > requests will grow with time (more users will come into the system), > the current server will become incapable of serving all the requests > quickly enough. > > The idea is to increase overall calculation capacity of the system by > adding more servers to it. Throwing more hardware to a single main > server is not an option in my case. Creating multiple replicas > (slaves) is also not an good option -- it would be way more efficient > to have a group of db servers, each serving only some subset of users > and hosting data for those users only. Buying new servers in advance > is not an option too. > > What I am looking for is switching some of the users to another db > server when the capacity of the existing server(s) is not enough. The > point is to do it without interrupting the users' work (so they do not > see that horrible "Sorry! This site is under maintenance..."). > > If I missed something it would be very kind of you to point this out. > > Thank you once again, > > -igorS > > *From:*Haifeng Liu [mailto:liuhaifeng@live.com] > *Sent:* May-29-12 9:13 PM > *To:* Igor Shmain > *Cc:* pgsql-admin@postgresql.org > *Subject:* Re: [ADMIN] Data split -- Creating a copy of database > without outage > > Why not use a partitioned table? You can write a trigger to control > which partition the coming data should be inserted. > > Regards, > > ---- > > Liu Haifeng > > Home: http://liuhaifeng.com > > > > On May 30, 2012, at 4:13 AM, Igor Shmain wrote: > > > > Can you please help with advice? > > I need to design a solution for a database which will grow and will > require a horizontal split at some moment. > > Here is how I am planning to do it: Every record in every table has a > shard number. After the database becomes too large (gets too many > requests), the tables need to be horizontally split. It means that for > every table all records with some specific shard numbers need to be > moved to a new database. > > My plan is to (1) create a copy of the database on a new server > (backup/restore?), (2) synchronize the databases (how?), and then (3) > forward all requests for the moved shards to the new database. (I will > get rid of the unneeded shards later). An important requirement: there > should be no outage for the users. > > What are the ways to achieve it? > > Thank you in advance, > -igorS > --------------090100090600090105020703 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Hi ,

I would start with a single high performance tuned database focusing mainly on dealing efficiently with concurrent activity and identifying the real hot spots.
If you check out that you really need to go forward on database power, consider on adding  new databases and relocate some users whenever you need it.

Take a look on the different options related to replication, tunning and database balancers, set up some testings and get a deeper understanding on your real needs and performance.

A.A.



On 05/30/2012 08:14 AM, Igor Shmain wrote:

Thank you, Liu, for your suggestion.

 

I might be missing something (I am new to postgres), but it seems that your suggestion will not help much in my case.  Since the number of db requests will grow with time (more users will come into the system), the current server will become incapable of serving all the requests quickly enough.

 

The idea is to increase overall calculation capacity of the system by adding more servers to it. Throwing more hardware to a single main server is not an option in my case. Creating multiple replicas (slaves) is also not an good option – it would be way more efficient to have a group of db servers, each serving only some subset of users and hosting data for those users only. Buying new servers in advance is not an option too.

 

What I am looking for is switching some of the users to another db server when the capacity of the existing server(s) is not enough. The point is to do it without interrupting the users’ work (so they do not see that horrible “Sorry! This site is under maintenance…”).

 

If I missed something it would be very kind of you to point this out.

 

Thank you once again,

-igorS

 

 

From: Haifeng Liu [mailto:liuhaifeng@live.com]
Sent: May-29-12 9:13 PM
To: Igor Shmain
Cc: pgsql-admin@postgresql.org
Subject: Re: [ADMIN] Data split -- Creating a copy of database without outage

 

Why not use a partitioned table? You can write a trigger to control which partition the coming data should be inserted.

 

Regards,

----

Liu Haifeng

 



 

On May 30, 2012, at 4:13 AM, Igor Shmain wrote:



Can you please help with advice?

I need to design a solution for a database which will grow and will require a horizontal split at some moment.

Here is how I am planning to do it: Every record in every table has a shard number. After the database becomes too large (gets too many requests), the tables need to be horizontally split. It means that for every table all records with some specific shard numbers need to be moved to a new database.

My plan is to (1) create a copy of the database on a new server (backup/restore?), (2) synchronize the databases (how?), and then (3) forward all requests for the moved shards to the new database. (I will get rid of the unneeded shards later). An important requirement: there should be no outage for the users.

What are the ways to achieve it?

 

Thank you in advance,
-igorS

 

 

--------------090100090600090105020703--