05.11.2015 Views

Apress.Expert.Oracle.Database.Architecture.9i.and.10g.Programming.Techniques.and.Solutions.Sep.2005

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

10<br />

CHAPTER 1 ■ DEVELOPING SUCCESSFUL ORACLE APPLICATIONS<br />

Use a Single Connection in <strong>Oracle</strong><br />

Now, in SQL Server it is a very common practice to open a connection to the database for each<br />

concurrent statement you want to execute. If you are going to do five queries, you might well<br />

see five connections in SQL Server. SQL Server was designed that way—much like Windows<br />

was designed for multithreading, not multiprocessing. In <strong>Oracle</strong>, whether you want to do five<br />

queries or five hundred queries, the maximum number of connections you want to open is<br />

one. <strong>Oracle</strong> was designed that way. So, what is a common practice in SQL Server is something<br />

that is actively discouraged in <strong>Oracle</strong>; having multiple connections to the database is something<br />

you just don’t want to do.<br />

But do it they did. A simple web-based application would open 5, 10, 15, or more connections<br />

per web page, meaning that the server could support only 1/5, 1/10, 1/15, or an even<br />

fewer number of concurrent users that it should have been able to. Additionally, they were<br />

attempting to run the database on the Windows platform itself—just a plain Windows XP<br />

server without access to the Datacenter version of Windows. This meant that the Windows<br />

single-process architecture limited the <strong>Oracle</strong> database server to about 1.75GB of RAM in<br />

total. Since each <strong>Oracle</strong> connection was designed to h<strong>and</strong>le multiple statements simultaneously,<br />

a single connection to <strong>Oracle</strong> typically takes more RAM than a single connection to SQL<br />

Server (but it can do a whole lot more). The developer’s ability to scale was severely limited on<br />

this hardware. They had 8GB of RAM on the server but could use only about 2GB of it.<br />

■Note There are ways to get much more RAM used in a Windows environment, such as with the /AWE<br />

switch, but this requires versions of the operating system that were not in use in this situation, such as<br />

Windows Server Datacenter Edition.<br />

There were three possible solutions to this problem, <strong>and</strong> all three entailed quite a bit of<br />

work (<strong>and</strong> remember, this was after the “port” was supposedly complete!). Our options were<br />

as follows:<br />

• Re-architect the application, to allow it to take advantage of the fact it was running “on”<br />

<strong>Oracle</strong> <strong>and</strong> use a single connection to generate a page, not somewhere between 5 to 15<br />

connections. This was the only solution that would actually solve the problem.<br />

• Upgrade the OS (no small chore) <strong>and</strong> use the larger memory model of the Windows<br />

Datacenter version (itself not a small chore either, as this process involves a rather<br />

involved database setup with indirect data buffers <strong>and</strong> other nonst<strong>and</strong>ard settings).<br />

• Migrate the database from a Windows-based OS to some other OS where multiple<br />

processes are used, effectively allowing the database to use all installed RAM (again,<br />

a nontrivial task).<br />

As you can see, none of the presented options is the sort of solution that would have you<br />

thinking, “OK, we’ll do that this afternoon.” Each was a complex solution to a problem that<br />

would have most easily been corrected during the database “port” phase, while you were in<br />

the code poking around <strong>and</strong> changing things in the first place. Furthermore, a simple test to<br />

“scale” prior to rolling out a production would have caught such issues prior to the end users<br />

feeling the pain.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!