Tuesday, December 20, 2011

Using DVDStore with PostgreSQL

We now have support for PostgreSQL in the popular DVDStore Benchmark which stresses database using an emulated DVDStore e-Commerce website. DVDStore Benchmark is maintained by Dave Jaffe (Dell) and  Todd Muirhead (VMware).  It is an open source database test kit. The beauty of the benchmark kit is it allows the same web application being deployed either as
  1. Java/Tomcat  and connect to the database,
  2. Web Server/PHP and connect to the database,
  3. IIS/ASP.NET connect to the database or
  4. Direct connect to the database and invoking the business logic as stored procedures stored on the database itself.

Currently the PostgreSQL implementation details are as follows
  1. Java/Tomcat using PostgreSQL JDBC driver,
  2. Web Server/PHP  using  PHP-postgres modules which uses  libpq
  3. Currently there is noIIS/ASP.NET web app  implementation for PostgreSQL
  4.  Direct connect to PostgreSQL database and business logic implemented in stored procedures however the driver is implemented using .NET C# and requires Npgsql 2.0.11.0

Setup instructions for the database are relatively quite easy.
  1. Download ds21.tar.gz  and also ds21_postgresql.tar.gz from  http://linux.dell.com/dvdstore/
  2. Unzip them on the system running PostgreSQL
  3. The default data size is 10MB. If you want a different size execute 'perl Install_DVDStore.pl' in the ds2 directory. (Expects perl to be available on the system. I used the option 100, MB , PGSQL, LINUX respectively for the options.)
  4. Assuming you are logged on as the DB Owner and the database is on the localhost at port 5432, execute the script pgsql_create_all.sh in the ds2/pgsqlds2 directory. It will create a database "ds2", two users "ds2/ds2" and "web/web", create tables, load tables, create indexes, update sequences and finally run analyze. (The script needs to be modified slighly if the database is already hardened and you want to control the creation of database and the users.)

Setup for the actual load driver is probably easiest on  another Windows platform as follows as it was designed for .NET platform.
  1. Download and install Windows SDK v6.1 and .NET 3.5 framework  on a Windows Client machine.
  2. Once installed start the CMD prompt from Programs-> Windows SDKv6.1-> CMD Prompt.
  3. Verify the above CMD prompt has path setup for gacutil in windows (Try 'gacutil/l')
  4. Download Npgsql 2.0.11 for msnet35 and install the dlls using the gacutil.exe (Note other versions of Npgsql may have issues.)
    •  gacutil/i Npgsql.dll
    •  gacutil/i Mono.security.dll
    •  gacutil/i policy-2.0.Npgsql.dll


With the above setup you can use the ds2webdriver.exe in ds2/drivers or the direct ds2pgsqldriver.exe in ds2/pgsqlds2. More on running the benchmark driver itself  in another post.

Thursday, October 27, 2011

How does PostgreSQL HA works in vFabric Data Director?

Databases go down due to various reasons. Some reasons are known and some unknown.
Common reasons are hardware failure, software failure, database unresponsive, etc. What is considered as a failure is actually one of the tasks. Various DBA's use a simple select statement as a test to make sure that the database is up and working. But what does one do if that simple select statement fails. I remembers years ago I worked on a module which will start paging  engineers in a sequence (and eventually their managers if the engineers failed to respond back in a certain expected way).  In this email/text age, scripts will start sending out emails and text messages.  What we are is basically in the Event->React-> Respond mode of operation.

However true HA needs to lower downtime which can  only be done by having the mode of operation as Event->Respond->React. To explain that when such an event happens, do an automated response first and then React to wake the engineers up :-)

How do you set this up in vFabric Data Director? This can be achieved by selecting the database properties, selecting the Database Configuration tab and set "High Availability" to "Enable". This is also refered as One-Click HA setting.

Of course this assumes that your virtual Data Cluster is set properly for providing the high availability services. How do you set it up properly? Well you need atleast two ESXi Hosts so if one host fails, the other can cover for it. Also vSphere HA property has been enabled in the Virtual Data Center Cluster. Note these settings are all "required" for vFabric Database setup and a "supported" setup does mandate atleast two ESXi Hosts in order for HA to work.

Now that we have gone over the setup requirements, lets go over the scenarios on how the application or user sees it.  A user is connected to the database using the connection string. Something happens and the database goes down and the connection drops. Chances are if you reconnect again immediately it may fail. However with certain time which is expected to be less than 5 minutes (which we call our Recovery Time Objective or RTO)  by default, if you try again you can connect to the database again.

So what happens in the background? Well if it was Magic, we would not tell you. But it is not really magic though it feels like that. Here is what will typically happen in the background.
For some reason the PostgreSQL fails to respond anymore it could be a "hung" situation or the PostgreSQL server has died. There is a small heartbeat monitor which figures out the status of the database. If it notices that the hung situation or no DB server process, it will try to restart the database. If the database cannot be restarted (because the whole VM appliance cannot respond anymore), it will in novice terms kill the virtual machine. The vCenter Server which has its own heartbeat on the VM appliance will see that the Virtual Machine has died (irrespective of the Database Monitor which may not be working if the whole host dies), the vCenter Server will restart the VM appliance on another server.

Since shared-storage is a requirement, the VM appliance will start on another host and it will feel like a reboot. Once the VM starts, the PostgreSQL server process will be restarted. At this point of time, the PostgreSQL server goes into recovery mode. The biggest question at this point of time typically is how long will the recovery mode take. Typically based on internal tests even with the heaviest workload on 8vCPU, the recovery time can finish within the checkpoint_timeout settings which means our Recovery Time Objective is guided by checkpoint_timeout + heartbeat latency + the time to restart the VM on another hosts.  Overall we try to fit that into our Recovery Time Objective of 5 minutes.

Great the virtual machine has restarted and the database has done its recovery and working again. Now what? Well dont forget in this cloud setup, the easiest thing is to use DHCP addresses. Unfortunately DHCP addresses are not guaranteed to be same after reboot . Plus rebooting on a different host makes it more complex to get the same IP. This IP address change can cause the Database connectivity to be lost to the actual end user.   In order to shield the end users from this complexity, we sort of implemented our own Database Name Server. However this can only work by modifying the clients which references the database using this "Virtual Hosts" format so that the clients can always find their intended database without really worrying about where it is running. A minor change in the PostgreSQL clients but a huge complexity reducer for end users to fix their IP addresses or domain names to the changed location.

Aha now this explains why vPostgres ships their own clients and libpq library which is API compatible with standard PostgreSQL libpq library.The libpq library is actually 100% compatible with standard PostgreSQL Libpq library. The only addition it has is the feature of Virtual Hosts which is critical for HA to work seemlessly without the users being concerned about the actual IP of the database. Without the change, HA will not work on the framework. Since it is 100% compatible, if an application works standard libpq it will work with vPostgres libpq. Similar changes are also done in the JDBC driver and ODBC Driver for vPostgres so HA is supported across all supported clients.

That said if you use standard libpq/psql and other standard clients and you know the IP Address of the vPostgres database and connect to it via that IP address (and not the virtual host string)  it will still work flawlessly. However if the database goes down and restarts with a new IP address then the client will have no ability to figure out the new IP address and will have to bug the Administrator to figure out the new IP address.

Though for folks familiar with vSphere terminology, HA is not FT - Fault Tolerant which is a different take on HA to further reduce downtime from minutes to seconds. More on that in future.

Thursday, October 13, 2011

Using PostgreSQL Server on Micro Cloud Foundry

With the recent news that PostgreSQL is now available in the Micro Cloud Foundry, I decided to take it for a test spin. I downloaded the Micro Cloud Foundry VM zip file which is about 1.0GB big. After downloading it I unzipped it on my MacBookPro and use VMware Fusion 4.0.2 to open the VM. As the VM booted up the console shows a message

Micro Cloud Foundry not configured

I selected the option 1 to configure the Micro Cloud. It asked me to configure my VM user password, Networking (DHCP or Static) and then asked me to enter my Cloud Foundry configuration token which was provided to me after I had created a pgtest.cloudfoundry.me domain  just before the download.

It took about 5 minutes to setup the cloud

After the setup: I got my micro cloud foundry setup with my local IP (looked like a bridge connection rather than NAT).

Then I installed the VMC tool on my Mac using  (Need Ruby)
(NOTE: Skip directly to ssh part if you donot want to install Ruby/vmc)

$ gem install vmc

$ vmc target http://api.pgtest.cloudfoundry.me

Got me connected to my micro cloud.
Then I did a
$ vmc register
to create my user account using a email id and password
Then I logged into the MicroCloud using
$ vmc login

Now when I do the following I see the PostgreSQL Service available with other databases also.

$ vmc services

============== System Services ==============

+------------+---------+---------------------------------------+
| Service    | Version | Description                           |
+------------+---------+---------------------------------------+
| mongodb    | 1.8     | MongoDB NoSQL store                   |
| mysql      | 5.1     | MySQL database service                |
| postgresql | 9.0     | PostgreSQL database service (vFabric) |
| rabbitmq   | 2.4     | RabbitMQ messaging service            |
| redis      | 2.2     | Redis key-value store service         |
+------------+---------+---------------------------------------+

=========== Provisioned Services ============
As you can see there are no provisioned services currently.


Here if you are like a Java/Spring developer you want to creating an application using Xin Li's post on "PostgreSQL for Micro Cloud Foundry- Spring Tutorial".

I am not interested in developing Java applications but I want access to the postgresql server directly.

Now comes the ssh part.

Currently the PostgreSQL server is not exposed externally from the Micro Cloud.
But on the console of Micro Cloud VM, you can configure the password of vcap user. Which means now you have ssh access to the Micro Cloud VM.

$ ssh vcap@mircrocloudip

$ cd /var/vcap/store/postgresql
$ vi postgresql.conf 

and edit listen_address to add your database client ip address out there.
For my demo setup I just opened it to all
listen_addresses='*'

Next assign a Postgres password for the "vcap" user
$ /var/vcap/packages/postgresql/bin/psql -d postgres
psql (9.0.4)
Type "help" for help.

postgres=# ALTER USER vcap WITH PASSWORD 'secret';
ALTER ROLE
postgres=#\q

Now I exit from Micro Cloud VM and using the console I restart the services.
Now the PostgreSQL service can be accessed from postgres client anywhere.

For example from a Macbook Pro

$ psql -h microcloudip -d postgres -U vcap
Password for user vcap:
psql (9.0.5, server 9.0.4)
Type "help" for help.

postgres=#


Try it out!

Friday, October 07, 2011

vFabric Data Director - All in a Box setup

vFabric Data Director 1.0 is available for download on the VMware download website. Generally the question we get a lot is on how to do a "small" setup for either a departmental setup or trial setup which is actually small enough to fit in a beefy workstation or a small server. Often time this helps people to evaluate the features of Data Director before doing the "standard" HA setup. Maybe it is only for tests/dev databases where one does not want to invest too much in the infrastructure setup itself..

So here is one such way of doing a "small" setup of vFabric Data Director for test/dev/qa databases.
(Note: This is going to be a long blog post)

What do you need?
  1. A beefy Workstation or departmental Server with lots of RAM and lots of Storage and atleast two network adapter (Even though only one need be connected to the departmental network)
  2. ESXi V5.0 installation CD (Software)
  3. vCenter  Virtual Appliance/Virtual Machine
  4. DHCP Server Virtual Machine
  5. vFabric Data Director Virtual Appliance Image
  6. Preferably atleast one static IP Address on your departmental network for DB Name Server or have Dynamic DNS on your departmental network
  7. License Keys - Use your VMware contacts.

Step I: Preparing the Workstation
On my test setup I had 12GB of RAM with 2x Quad Core x86_64 chips with 5 disks in it. Since this is my whole setup, the more memory I get, the merrier I am with the setup. It is recommended that you have some sort of Raid controller on the setup and have ability to create multiple LUN devices that will be exposed to the ESXi server. On my setup I had about one disk dedicated to ESXi and for other disks I created a RAID-5 LUN (RAID-10 is preferred but I did not have enough space on my demo setup).  If I had more Storage available I would do two setups with RAID-10 setup and a RAID-0 setup which can be used as backup datastore. The RAID preferences depends on individual needs on what to trade off (performance , availability, capacity).

Step II: Installing ESXi 5.0 
Using the ESXi V5.0 installation CD, I installed ESXi  on the first logical device and eventually setup the RAID protected device as a datastore that ESXi can use.

Step III: Install vCenter Virtual Machine
Here one can use the vCenter Virtual Appliance available also. On my demo setup I had used a vCenter Server based on Windows Server 2003 since that was available. Installation of vCenter Server itself can be its own blog entry and I will leave that to experts. For my purpose I had setup vCenter Server setup done in a virtual machine.

Step IV: Setting up vCenter Server for our task
This is where things are bit different for this special all in a box setup. The idea of setting up is to do vFabric Data Director Appliance which includes the hardware. Hence the idea is only the management console and the databases that it deploys are exposed outside (of course the ESXi also has to be visible outside to set this up)  and all other infrastructure related things are hidden within this appliance. This is where two network adapters will come in play. Lets go first with the steps and then a bit of explanation on why do it this way.
I am assuming that the ESXi Server and  vCenter VM has network connected to the live network adapter.
  • Connect to the vCenter through vSphere GUI or through the webclient.
  • Create a new DataCenter. 
  • Create a new Cluster
  • Add the ESXi Host to this cluster
  • Edit Settings for the Cluster to Enable
    • vSphere HA (even though we cannot do it on a single Host)
    • vSphere DRS
    • "VM and Application Monitoring" in VM Monitoring
  • Create a Distributed vSwitch as follows:
    • Go to networking in Inventory you will see your corporate network called probably "VM Network"
    • Add a new distributed vSwitch in the section where you have to add a physical Network Adapter, select the Network Adapter which is not plugged into the departmental network (Skip creating an automatic port group for the switch)
    • Now for the dvSwitch created, create two port Groups "vCenter Network" and "Internal Network"
  • For the ESXi host create a vmKernel port in "vCenter Network" portgroup with a static IP address 192.168.2.2
  • For the vCenter VM, create a new network adapter in the "vCenter Network" port group with a static IP of 192.168.2.1
  • Change the Managed IP of vCenter Server (Administration->vCenter Server Settings->Runtime Settings)  to 192.169.2.1
  • Make sure vCenter server can still access the ESXi server through the new "vCenter Network" portgroup
  • Setup DHCP Server Appliance such that its LAN network is on "Internal Network"
    • I had setup DHCP  Server such that its own IP is 192.168.1.1 and it does DHCP on the network from range 192.168.1.5 to 192.168.1.250 (for my demo setup)

Step V: Deploy vFabric Data Director OVA Template
  • Using the vSphere Client (connected to our vCenter Server) deploy the vFabric Data Director OVA template. 
  • The setup wizard will ask you to select the network for vCenter and the Management console. For the vCenter Network select the "vCenter Network" portgroup and for the Management Console, select the "VM Network" which is the live departmental network
  • If your setup is like mine, I do not have access to static IP adddress in the deparmental network so I just leave the next screen at its defaults to use DHCP and finish the deployment. 
Once the deployment finishes  there will be a new vApp called VMware Data Director.
  • Start the vAPP.  Once the vAPP starts, expand the "+" sign and select to the Management Server VM. 
  • Select the "Summary" tab of Management Server and wait till it shows an IP address.
  • Enter  that IP address in a browser and you should see message "This connection is untrusted" depending on your browse type, add it to your exceptions and then it should take you to License agreement screen. 

Step VI: Setup vFabric Data Director
  • Read and accept the License agreement to proceed. 
  • Next create an administrator account.
  • On the next screen since this is a small setup, I selected the Global User Management Mode
  • Setup the Branding as required on the next screen
  • Setup the SMTP server information if available (needed for user password resets) (You also need outgoing email id for a successful setup of SMTP )
  • On the next screen you have to setup vCenter Network Information. Since we dont have any DHCP on our "vCenter Network" portgroup, edit Network adapter settings and select "Static" with netmask information 255.255.255.0
  • Set static IP addresses 192.168.2.3 for Management server and 192.168.2.4 for DB Name Server
  • On the next screen change Internal Network to select "Internal Network" portgroup and leave DB Name Server Network as the "VM Network" which is the departmental network.
  • On the following screen, select the network settings of "Internal Network"  DHCP should be already selected. Also check Static and add the network mask as 255.255.255.0
  • For Management Server - Internal Network adapter, select static IP address and set it to 192.168.1.3
  • For DB Name Server - Internal Network adapter, select static IP address and set it to 192.168.1.4
  • Warning: This next bit is where you use your one static IP address or Dynamic DNS based FQDN requirement. We still have to provide DB Name Server - DB Name Service Network Adapter. If you have any influence on your IT, get a static IP address for this one. If you get the static IP, then click the Departmental "VM Network" setup and select static IP address with the associate Gateway, netmask and DNS Server setup. Then  set the static IP address for DB Name Server - DB Name Service Network Adapter with the static IP address that you get from your IT..
  • Next enter your Evaluation License keys for vFabric Data Director and vFabric Postgres
  • Finally verify information on the summary page and then click Finish
  • You should get a login screen if it sets up successfully
Note: The most tricky bit is getting the IP address from IT. If for some reasons you do not have a static IP address, fake a  fully qualified domain name for DHCP. Once setup and you get a login screen. Figure out the DHCP IP allocated to DB Name Server using vSphere Client (It is first IP address that shows in the Summary tab of DB Name Server VM). Enter using your administrator account credentials, go to "Administration" tab. Select Settings-> Networking setup. Select Edit Network Setup and step through the setup again and change your fakeFQDN with the DHCP IP address and press finish. Of course this is a hack and not recommended since DHCP IP addresses can change anytime if the lease is up or the system is rebooted and other network policies.

Step VII: Setting Up  an Resource Bundle in vFabric Data Director
For this we need a special Resource Pool in our Virtual Data Center
  • Using vSphere Client we create a resource Pool "Resource Bundle1" in the data center
  • Edit its settings such that it has reservations and limits matching for both CPU and memory
  • Also "Unlimited" should not be checked for both CPU and Memory. 
  • In my demo setup I set CPU reservations and limits to 4096MB and Memory reservations and limits to 4096 MB.
Enter the vFabric Management Console using your administrator credentials and go to "Manage & Monitor" tab.
  • Select "Resource Bundle" and create a new resource Bundle "ResourceBundle1".
  • If the setup is right the next screen should show you the CPU/Memory Resource Pool that we created "Resource Bundle1"  
  • Next select the RAID protected datastore and a size chunk off it for Database Storage. Select any alternative or the same datastore for "Backup Storage" with a sizeable chunk. In my demo I selected my Raid5 based datastore and 100GB sizes for both.
  • Next select the "VM Network" which is my departmental network through which uses will access the database. 
  • Click Finish to setup the Resource Bundle.


Step VII: Setup an Organization in vFabric Data Director
In "Manage&Monitor" select Organizations and create "+" a new organization called "DataDirectorOrg".
  • On the next screen you could select an new user or in my case I used "Choose an existing user" and used my administrator account to manage the Organization also.
  • Next I selected the resource Bundle I just created (need to select "Choose an existing Resource Bundle" to see the resource bundle) 
  • click Finish.
Once created there will be the new Org displayed. If you select it once, the link becomes active. If you then select the active link again it will open a New tab for the Organization for our next step.


Step VIII: Setup a Database Group
Next we have to setup a database group.
  • In the org tab select "Manage&Monitor" tab to see the list of databases (which is empty). 
  • Select the second tab "Database Groups"  to see the empty group list
  • Create ("+" ) a new database group "DBGroup1" where I selected half of my datastore resources assigned for this group leaving the rest of the entries at default.


Step IX: Create a database
  • Select and enter the database group we just created.
  • Create ("+") a new database "dbtest" with owner credentials "dba" and password.
  • Wait till deployment of the database succeeds and "dbtest" is running. 
  • Once running highlight it , right click to see the properties and get the UUID and Name. The client also needs the IP address of the DB Name server.
Here is an image of the distributed vSwitch from vSphere client on my demo box.





Step X: Connect to the database from a client
Download vPostgres Clients for your platform. Then using psql from the client connect to the database similar to the following example
psql -h {dd9fce1e-db46-4a08-99a1-e9023b8239fe}.129.55.555.55 -d dbtest1 -U dba

It should prompt for the dba password and now you are connected to the database and the setup is working. Check out my previous blog entry on how to use vPostgres Clients.

Finally now the setup of vFabric Data Director all in a box setup is working and tested.

Thursday, September 29, 2011

#PGWest 2011 - Using vFabric Postgres - A DB User's Perspective

Here are my slides from my #PGWest 2011 Presentation " Using vFabric Postgres - A DB User's Perspective" for vPostgres Databases as  deployed by vFabric Data Director.

Sunday, September 18, 2011

Next Stop: #PgWest 2011 - San Jose

Returned back from a great #pgopen in Chicago. It was nice to also see and meet again senior VMware executives, PostgreSQL community members and lot of folks (aka customers or potential customers ) who use PostgreSQL as key databases in their IT setup  in the conference.

Next stop now is #PgWest 2011 in San Jose starting on Septeber 27,2011. This year again #PgWest is in San Jose, California.

At this conference, I am presenting my first ever "Using vPostgres - A DB User perspective". The gist of this presentation is on how to use the vFabric Postgres client with the vFabric Postgres server deployed by vFabric Data Director. There are some small differences on how the client works compared to community PostgreSQL  and we will go over those in the session on exactly how it works, and see on how you use it for running and developing your own applications with it.

Also Alex Mirgorodskiy, VMware will be first time presenting in a PostgreSQL conference (that I am aware of at this point of time) on "vFabric Postgres Database Internals".  In this session Alex will go over the subtle tansparent changes which makes vFabric Postgres so easy to deploy, manage and perform in the vFabric Data Director world. Not to steal his thunder but this will cover the new Elastic Database Memory in detail.

Bill Hodak, VMware will present  about  vFabric Data Director itself on how it leverages the features of PostgreSQL and provide a management framework over it to provide enterprise framework and provide self-service features making it easy for even folks who donot know a lot about PostgreSQL database itself to deploy, tune, monitor, backup, restore, clone the database instances.

And to give an overview of VMware's commitment to PostgreSQL Community, Charles Fan, Sr.VP - VMware R&D will be presenting the keynote at #PgWest 2011.

Overall pretty excited about the conference and  to meet lot of new people in the bay area.

Thursday, September 15, 2011

Running PostgreSQL on Virtual Environments - #pgopen 2011

Slides from my presentation  at Postgres Open 2011 (#pgopen11) in Chicago.



Tuesday, September 13, 2011

Next Stop: Postgres Open 2011 - Chicago

Soon I will be in Chicago for Postgres Open 2011. Here I will be presenting once again 
"Running PostgreSQL on Virtualized Environments"  on Thurday - 11:30am in the Cotillion Ballroom (according to the current schedule).

The title should really be "Running Community PostgreSQL on Virtualized Environments" since this presentation really applies to the experiences of running community PostgreSQL in Virtual Machines.  Most of the things in the presentation should really be a checklist which helps you get the most of PostgreSQL in VMs. Of course depending on the VM and the underlying infrastructure, your mileage may vary.

Overall I am also looking forward to attend other sessions (besides mine of course) . Greg Smith has couple of sessions which sounds interesting. There is key note by  Charles Fan on Friday  (that should be no brainer for me). Probably the most interesting to me is "Unlocking the Postgres Lock Manager" by Bruce Momjian which definitely is in line of my interest (since I try to control/avoid/reduce lock contentions and LWLocks in benchmarks which actually lead to my past presentation in pgcon on "Understanding Postgres LWLocks").

Definitely looking forward for the trip.

Monday, August 29, 2011

VMware vFabric Data Director, VMware vFabric Postgres and CloudFoundry

Today I am finally pleased to see that we are finally moving out of stealth mode.

VMware announced vFabric Data Director at VMworld 2011 along with vFabric Postgres (vPostgres).  You will find lot of information already in the press release.

VMware vFabric Data Director



vFabric Data Director is a new VMware software product that enables enterprises to offer Database-as-a-Service. vPostgres is the the first database supported on vFabric Data Director.
It is  a self-service product which  takes the repetitive tasks of setting up a database right from virtual bare-metal to a fully running databases in minutes with features that you expect with an Enterprise quality database (deploying, monitoring, backup, restore, resizing, cloning and many other features). It helps to reduce the database sprawl and increases DBA productivity to handle large number of databases. It extends the vSphere platform to now include a data tier.

You can find the product document, a product-demo and other information on the resource page of  vFabric Data Director.

VMware vFabric Postgres (vPostgres)


vFabric Postgres is VMware's version of PostgreSQL. vPostgres is optimized for running on vSphere platforms. It is based on PostgreSQL 9.0. However there are some transparent changes which are significant in overall user experience.  Lets go over few of these key features

  • vFabric Postgres Elastic Database Memory: vPostgres Elastic database memory allows dynamic and seamless adaption of bufferpool in response to changing workloads on the hypervisor.  In traditional implementation, if you take out memory, the guest VMs  performance will goes down the drain. Most cloud users will have seen the symptoms for sure.  With vPostgres Elastic database memory , the effective bufferpool shrinks based on memory pressure dynamically and allows the overall system to be more graceful to this changing memory pressures.  This feature reduces the   over-the-cliff drop in performance observed frequently in Cloud deployments of  databases.
  • Dynamic Checkpoint Tuning: In vPostgres, the priority is given to checkpoint_timeout which is referred to as Recovery Time Objective. In order to do the right balance between this Recovery Time Objective and overall performance, it dynamically shifts checkpoint_segments to keep a fine balance of adherence to RTO, performance and diskspace for WAL Logs. This allows reduction of manual tuning of checkpoints and allow the database server to dynamically find an optimum point based on changing workload.
  • vPostgres also has some specific features when used with vFabric Data Director. vFabric  Data Director allows to change resources (vCPU, memory) set for a particular database. vData Director can then auto-tune the database based on the changed resources minimizing significantly the time to re-tune database. This allows DBAs to focus on more "business goal related tasks rather than day-to-day maintenance tasks.

Currently vPostgres will be only available for download as part of  vFabric Data Director. However there is a vPostgres Service available on CloudFoundry.com for Cloud Applications. It is free for use by all applications that support the Cloud Application programming which includes Java, Ruby, node.js  in CloudFoundry.com.


$ vmc services

============== System Services ==============

+------------+---------+-------------------------------+
| Service    | Version | Description                   |
+------------+---------+-------------------------------+
| mongodb    | 1.8     | MongoDB NoSQL store           |
| mysql      | 5.1     | MySQL database service        |
| postgresql | 9.0     | PostgreSQL database service   |
| rabbitmq   | 2.4     | RabbitMQ messaging service    |
| redis      | 2.2     | Redis key-value store service |
+------------+---------+-------------------------------


During a cloud deployment, you could select the "postgresql" service for your application.
More on CloudFoundry services  in a subsequent blog posts.

Saturday, August 27, 2011

VMworld 2011 - Las Vegas

Arrived in Las Vegas early in the middle of the night for VMworld 2011 before Hurricane Irene hits the north east coast. In last few years,  this will be my first out of state conference which is not completely dedicated to PostgreSQL that I am attending. I am part of the Hands On Labs at VMworld which I heard are pretty popular in VMworld.  For database lovers I would recommend the
#HOL12 Optimizing Data Access for Your Cloud Infrastructure
It will be pretty interesting.  Also there are many other Performance tuning sessions which will be also very interesting.

Also there are many sessions available which may be difficult to short list. One of the things that is different from my other conferences that I attend is that one has to pre-register for the HOL or any sessions that one wants to attend otherwise they are denied entry to that session.  That is way difference and I still havent got around to figure out how the whole schedule builder works myself. So I would advice some extra time to make sure you can select your favorite sessions before they fill up.



Friday, May 20, 2011

Understanding PostgreSQL LWLocks - PGCon 2011


From PGCon 2011 here are my slides on "Understanding PostgreSQL LWLocks"




Or alternatively at the direct link.

Thursday, March 24, 2011

Running Postgres in Virtualized Environment - #pgeast 2011

Slides from today's presentation at PGEast.


As usual feedback, questions welcome.

Wednesday, March 23, 2011

Introduction to PostgreSQL for System Administrators - #pgeast 2011

Here are the slides from my presentation today at PGEast 2011.



It turned out to be a fast faced presentation for 45 minutes. Online feedback, questions are welcome as usual.


Update: Also my next presentation "PostgreSQL in Virtualized Environments" has moved to tomorrow (Thurday) at 9:00am in the Boardroom for the early bird attendees :-)


Wednesday, March 16, 2011

PgEast 2011 - New York

Its less than week for PgEast 2011  and this time I have two sessions out there.

My first session is on Wednesday at 3:00pm titled "Introduction to PostgreSQL for System Administrators" . This session is not about learning SQL or any real database feature but it is meant for system administrators to get their first exposure to PostgreSQL as an application running on their systems. We look at basic installation and some internals on understanding the various processes running on the system and understanding them.

My session session is on Friday at 10:05am titled "Running Postgres on Virtualized Environments". This session is about running Postgres in VM using VMware's vSphere. Many of the content while specific to vSphere can be used to understand in general when running Postgres on any virtual platform. 

With the increase in adoption of "Cloud Computing"  in various industries, I expect the usage of Postgres on VMs to increase dramatically in next few years. PgEast 2011 has a roundtable discussion with a panel of experts on Thursday at 2:30pm to precisely answer questions about deploying PostgreSQL in the cloud.





Monday, November 22, 2010

PostgreSQL 9.0 Simple Select Scaling using sysbench

While I still haven't found a working way to test sysbench read-write test, I decided to continue on sysbench testing with PostgreSQL 9.0. This time I selected the oltp-test-mode=simple which essentially does a select lookup based on a primary key. The basic idea is to see if you are only doing a select statement how far can you scale.

Here are my initial results with PostgreSQL 9.0



This is still work in progress in some ways since this test has never been done before with PostgreSQL 9.0 (or atleast I haven't seen any body publish anything around this before).

Anyway my real goal is not to just put the numbers here but to understand what is happening here. Round about 40-48 clients we seen to peak out on scaling and hit a wall as far as scaling goes. The statement is pretty simple select from sbtest with a primary key which is randomly generated.

This is where I miss dtrace and OpenSolaris. Now that I am working on Linux it thought of trying it out with systemtap. The setting up of a working systemtap itself was a big challenge and took me some time to make it to work on my existing kernel. (Boy Linux should get their act straight at user level tracing. Its not omnipresent as dtrace on Solaris).

I converted my old lockstat utility to work on systemtap. The script seems to work but systemtap can act funny sometimes like dont abruptly exit from systemtap  otherwise it may send a "wrong" signal to postgres backend which then just commits suicide since it cannot figure out what to do with such "trace/debug" signal.

        LOCKNAME LWID M W/A COUNT SUM-TIME(us) MAX(us) AVG-TIME(us)
      LockMgrLock 45 Ex W   85343 469682510 13152 5503
      LockMgrLock 57 Ex W   57547  30903727  8313  537
      LockMgrLock 44 Ex W     390     34061  1670   87
      LockMgrLock 59 Ex W     375     41570  2032  110
      LockMgrLock 56 Ex W     361     39685  1889  109
      LockMgrLock 47 Ex W     344     24548  1564   71
      LockMgrLock 54 Ex W     335     67770  2319  202
      LockMgrLock 50 Ex W     325     44213  1690  136
      LockMgrLock 49 Ex W     325     39280  1475  120
      LockMgrLock 55 Ex W     323     39448  1584  122
      LockMgrLock 48 Ex W     323     26982  1669   83


What you see above is top WAITS on lwlocks by count and what was the average wait and max wait time for a particular LWLock.

(Thinking it might be related to NUM_LOCK_PARTITIONS, I did some experiments with different sizes but since they are all related to the same table it does not help here.)

Then I modified my lockstat script slightly to do stack straces for those two locks:

Majority of those were pretty much caused by the same code path:

Lock id:45, LockMode:0
 0x000000000062412e : LWLockAcquire+0x25e/0x270 [/usr/local/aurora-1.0/bin/postgres]
 0x00000000006228cc : LockAcquireExtended+0x2dc/0xa40 [/usr/local/aurora-1.0/bin/postgres]
 0x0000000000620788 : LockRelationOid+0x48/0x60 [/usr/local/aurora-1.0/bin/postgres]
 0x000000000064be85 : AcquireExecutorLocks+0xd5/0x190 [/usr/local/aurora-1.0/bin/postgres]
 0x000000000064c96a : RevalidateCachedPlan+0x5a/0x3b0 [/usr/local/aurora-1.0/bin/postgres]
 0x000000000062ee64 : exec_bind_message+0x604/0xab0 [/usr/local/aurora-1.0/bin/postgres]
 0x0000000000630bbd : PostgresMain+0x82d/0x16e0 [/usr/local/aurora-1.0/bin/postgres]
 0x00000000005f302e : ServerLoop+0x96e/0xcb0 [/usr/local/aurora-1.0/bin/postgres]
 0x00000000005f3dec : PostmasterMain+0xa7c/0x1150 [/usr/local/aurora-1.0/bin/postgres]
 0x000000000044e4f0 : main+0x370/0x430 [/usr/local/aurora-1.0/bin/postgres]

Lock id:57, LockMode:0
 0x000000000062412e : LWLockAcquire+0x25e/0x270 [/usr/local/aurora-1.0/bin/postgres]
 0x00000000006228cc : LockAcquireExtended+0x2dc/0xa40 [/usr/local/aurora-1.0/bin/postgres]
 0x0000000000620788 : LockRelationOid+0x48/0x60 [/usr/local/aurora-1.0/bin/postgres]
 0x0000000000477425 : relation_open+0x55/0x90 [/usr/local/aurora-1.0/bin/postgres]
 0x000000000047e5e3 : index_open+0x13/0x90 [/usr/local/aurora-1.0/bin/postgres]
 0x00000000005732a5 : ExecInitIndexScan+0x125/0x1e0 [/usr/local/aurora-1.0/bin/postgres]
 0x0000000000560275 : ExecInitNode+0x135/0x290 [/usr/local/aurora-1.0/bin/postgres]
 0x000000000055ed80 : standard_ExecutorStart+0x530/0xc70 [/usr/local/aurora-1.0/bin/postgres]
 0x000000000063278b : PortalStart+0x1bb/0x380 [/usr/local/aurora-1.0/bin/postgres]
 0x000000000062ee9c : exec_bind_message+0x63c/0xab0 [/usr/local/aurora-1.0/bin/postgres]
 0x0000000000630bbd : PostgresMain+0x82d/0x16e0 [/usr/local/aurora-1.0/bin/postgres]
 0x00000000005f302e : ServerLoop+0x96e/0xcb0 [/usr/local/aurora-1.0/bin/postgres]
 0x00000000005f3dec : PostmasterMain+0xa7c/0x1150 [/usr/local/aurora-1.0/bin/postgres]
 0x000000000044e4f0 : main+0x370/0x430 [/usr/local/aurora-1.0/bin/postgres]


So what I understand is that we have two problems here:
1. RevalidateCachedPlan (the Major bottleneck)
2. AccessShare Lock entry (the second bottleneck)

Well atleast now I know the area where there seems to be some scaling bottlenecks which can limit simple SELECT statement scalings. The question now is what to do about them. Back to the mailing list.