{
  "date": "2015-09-13T10:12:19",
  "slug": "database-cloud-service-performance-network",
  "link": "https://www.dbi-services.com/blog/database-cloud-service-performance-network/",
  "title": {
    "rendered": "DataBase Cloud Service performance – Network"
  },
  "content": {
    "rendered": "<h2>By Franck Pachot</h2>\n<p>.<br />\nIn previous posts, I&#8217;ve installed <a href=\"http://dbi-services.com/blog/slob-in-the-cloud-how-to-check-cloud-services-performance/\" title=\"SLOB in the Cloud: how to check Cloud Services performance\">SLOB on the Cloud Services</a>, measured <a href=\"http://dbi-services.com/blog/database-cloud-service-performance-iops/\" title=\"DataBase Cloud Service performance – IOPS\">IOPS</a> and <a href=\"http://dbi-services.com/blog/database-cloud-service-performance-cpu/\" title=\"DataBase Cloud Service performance – CPU\">CPU</a>.<br />\nThere&#8217;s another resource that is even more important in a cloud environment: network.<br />\n<!--more--></p>\n<h1>Tuneling port 1521 over ssh</h1>\n<p>I&#8217;ve create a virtual instance by default where only ssh is opened:<br />\n<a href=\"https://www.dbi-services.com/blog/wp-content/uploads/sites/2/2022/04/CaptureCloudNetwork.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"https://www.dbi-services.com/blog/wp-content/uploads/sites/2/2022/04/CaptureCloudNetwork.jpg\" alt=\"CaptureCloudNetwork\" width=\"1012\" height=\"385\" class=\"alignnone size-full wp-image-3786\" /></a><br />\nI don&#8217;t want to open other port, so I&#8217;m using it with ssh tunneling. Let&#8217;s see how to tunnel port 1521:</p>\n<pre><code>\nssh -i ~/.ssh/cloud-fr/id_rsa -L9011:localhost:1521 140.86.3.101\n</code></pre>\n<p>This connects to my VM on the cloud and forwards the port 1521 (my listener port on that VM) to my local host (my laptop) port 9011.<br />\nWhich mean that I can connect to my database from my laptop:</p>\n<pre><code>\n$ tnsping //localhost:9011\n&nbsp;\nTNS Ping Utility for 64-bit Windows: Version 12.1.0.1.0 - Production on 12-SEP-2015 17:34:44\n&nbsp;\nCopyright (c) 1997, 2013, Oracle.  All rights reserved.\n&nbsp;\nUsed parameter files:\nF:\\ora\\product\\12.1.0\\client_1\\network\\admin\\sqlnet.ora\n&nbsp;\nUsed HOSTNAME adapter to resolve the alias\nAttempting to contact (DESCRIPTION=(CONNECT_DATA=(SERVICE_NAME=))(ADDRESS=(PROTOCOL=TCP)(HOST=127.0.0.1)(PORT=9011)))\nOK (90 msec)\n</code></pre>\n<p>Note that the time to ping is 90 milliseconds here. I&#8217;m in Switzerland and I&#8217;m connecting to the European cloud (in Amsterdam).<br />\nIf I do the same to the US cloud I have to cross the Atlantic:</p>\n<pre><code>\nAttempting to contact (DESCRIPTION=(CONNECT_DATA=(SERVICE_NAME=))(ADDRESS=(PROTOCOL=TCP)(HOST=127.0.0.1)(PORT=9061)))\nOK (240 msec)\n</code></pre>\n<p>But we will see that later.</p>\n<p>I don&#8217;t want to type the above ssh line everytime I want to connect to the cloud, so I use put the following in my ~/.ssh/config file: </p>\n<pre><code>\nHost test-cloud-fr\n        HostName 140.86.3.101\n        Port 22\n        User oracle\n        IdentityFile    ~/.ssh/cloud-fr/id_rsa\n        LocalForward    9011 test-perf:1521\n        LocalForward    9012 test-perf:5500\n</code></pre>\n<p>Then a simple &#8216;ssh test-cloud-fr&#8217; will connect the the right IP address, with the oracle user, using the right rsa private key and forwarding the listener and the EM express ports.</p>\n<p>If you connect with SQL Developer, you don&#8217;t need to do that. Check Jeff Smith blog about <a href=\"http://www.thatjeffsmith.com/archive/2015/07/connecting-to-the-oracle-cloud-database-as-a-service-dbaas/trackback\">Connecting to the Oracle Cloud</a>.</p>\n<h1>Latency</h1>\n<p>If you put your database in the cloud, you will put the application server there as well.<br />\nBut if you are in client/server with the client on your desktop, or if you are a developer and connect from your PC, then latency can be a concern.<br />\nHere I&#8217;m selecting 90000 rows from the European cloud (the one with a 90 ms latency) to my local sqlplus:</p>\n<pre><code>\nSQL&gt; set time on timing on autotrace trace stat\n09:07:25 SQL&gt; select * from dba_objects;\n&nbsp;\n91718 rows selected.\n&nbsp;\nElapsed: 00:05:15.72\n&nbsp;\nStatistics\n----------------------------------------------------------\n          0  recursive calls\n          0  db block gets\n      13000  consistent gets\n          0  physical reads\n          0  redo size\n    4439199  bytes sent via SQL*Net to client\n      67754  bytes received via SQL*Net from client\n       6116  SQL*Net roundtrips to/from client\n          0  sorts (memory)\n          0  sorts (disk)\n      91718  rows processed\n&nbsp;\n09:12:46 SQL&gt;\n</code></pre>\n<p>5 minutes is a lot, but that can be improved a lot. SQL Plus default fetchsize is 15 which is very low. This is why there are 6116 roundtrips (=91718/15) and it takes on average 51 ms per roundtip.<br />\nBut if we increase the fetchsize:</p>\n<pre><code>\n09:12:46 SQL&gt; set arraysize 5000\n09:12:54 SQL&gt; /\n&nbsp;\n91718 rows selected.\n&nbsp;\nElapsed: 00:00:07.01\n&nbsp;\nStatistics\n----------------------------------------------------------\n          0  recursive calls\n          0  db block gets\n       6991  consistent gets\n          0  physical reads\n          0  redo size\n    3870546  bytes sent via SQL*Net to client\n        698  bytes received via SQL*Net from client\n         20  SQL*Net roundtrips to/from client\n          0  sorts (memory)\n          0  sorts (disk)\n      91718  rows processed\n&nbsp;\n09:13:04 SQL&gt;\n</code></pre>\n<p>Now getting 100000 rows in 7 seconds is correct.<br />\nRemember that all default fetchsize (SQL Plus, jdbc, hibernate, etc) are too low.<br />\nIt is even more important with remote databases over WAN, such databases in the cloud.</p>\n<h1>Latency under the Atlantic</h1>\n<p>I have run a tnsping from US cloud to EU cloud every second during one week, and the same in the opposite way. Here is the result:</p>\n<table>\n<tr>\n<td>\n<a href=\"https://www.dbi-services.com/blog/wp-content/uploads/sites/2/2022/04/CaptureLatency2.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"https://www.dbi-services.com/blog/wp-content/uploads/sites/2/2022/04/CaptureLatency2.jpg\" alt=\"CaptureLatency2\" width=\"300\" height=\"207\" class=\"alignnone size-medium wp-image-3791\" /></a>\n</td>\n<td>\n<a href=\"https://www.dbi-services.com/blog/wp-content/uploads/sites/2/2022/04/CaptureLatency1.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"https://www.dbi-services.com/blog/wp-content/uploads/sites/2/2022/04/CaptureLatency1.jpg\" alt=\"CaptureLatency1\" width=\"300\" height=\"206\" class=\"alignnone size-medium wp-image-3792\" /></a></p>\n<tr>\n</table>\n<p>The latency is quite stable around 170 and 180 milliseconds. Rarely over 200ms.<br />\nHere are the only 3 peaks observed during that week:</p>\n<pre><code>\nMon Sep  7 15:15:01 EDT 2015 US-&gt;FR OK (1880 msec)\nFri Sep 11 15:00:18 EDT 2015 US-&gt;FR OK (410 msec)\nWed Sep  9 19:00:16 EDT 2015 EU-&gt;US OK (530 msec)\n</code></pre>\n<p>If it stays like that, the latency is acceptable for a DataGuard in ASYNC.<br />\nOracle will provide Data Guard service, but if you want to put a Data Guard between US and EU it&#8217;s possible in maximum performance.</p>\n<h1>Bandwith under the Atlantic</h1>\n<p>Finally, here is a small test to measure the bandwidth between the European Cloud Services and the US one<br />\nI copy a big file with scp:</p>\n<pre><code>\n[oracle@test-cloud-us ~]$ scp test-cloud-fr:/u02/IOPS.dbf /dev/null\nIOPS.dbf                            6% 5004MB   8.0MB/s 2:27:59 ETA\n</code></pre>\n<p>8MB/s. Here doing the same but with compression:</p>\n<pre><code>\n[oracle@test-cloud-us ~]$ scp -C test-cloud-fr:/u02/IOPS.dbf /dev/null\nIOPS.dbf                            7% 5564MB  17.4MB/s 1:08:02 ETA\n</code></pre>\n<p>But this is only to give an idea.</p>\n<h1>So what?</h1>\n<p>The DBaaS is just a remote database. Latency is always something to consider: avoid to do unnecessary roundtrips when fetching data.<br />\nWhen you will consider to move your databases to the cloud, you will have to think about how to transfer it. There are several options to consider to minimize downtime: Physical replication (Data Guard or Dbvisit standby), Logical replication (Golden Gate or Dbvisit replicate), data virtualization (Delphix), etc.</p>\n",
    "protected": false
  }
}
