13.07.2015 Views

Software Engineering for Internet Applications - Student Community

Software Engineering for Internet Applications - Student Community

Software Engineering for Internet Applications - Student Community

SHOW MORE
SHOW LESS

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

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

(config_param_seq.currval, 1, '/wtr/thebook/');insert into config_param_values values(config_param_seq.currval, 2, '/panda/');commit;At the end of every page script we can query these tables:select cpv.param_valuefrom config_param_keys cpk, config_param_values cpvwhere cpk.config_param_key_id =cpv.config_param_key_idand key_name = 'view_source_link_p'If the script gets a row with "t" back, it includes a "View Source" linkat the bottom of the page. If not, no link.Recording a redirect required the storage of two rows in theconfig_param_values table, one <strong>for</strong> the "from" and one <strong>for</strong> the"to" URL. When a request comes in the Web server will want to queryto figure out if a redirect exists:select cpk.config_param_key_idfrom config_param_keys cpk, config_param_values cpvwhere cpk.config_param_key_id =cpv.config_param_key_idand key_name = 'redirect'and value_index = 1and param_value = :requested_urlwhere :requested_url is a bind variable containing the URLrequested by the currently-connected Web client. Note that this querytells us only that such a redirect exists; it does not give us thedestination URL, which is stored in a separate row ofconfig_param_values. Believe it or not, the conventional thing todo here is a 3-way join, including a self-join ofconfig_param_values:select cpv2.param_valuefromconfig_param_keys cpk,config_param_values cpv1,config_param_values cpv2where cpk.config_param_key_id =cpv1.config_param_key_id146up-to-date version of the commonly used portions of the database inRAM. So our multi-computer RDBMS server that ensures databasecoherency across processors via reference to the hard disk will startout 100,000 times slower than a single-computer RDBMS server.Typical commercial RDBMS products, such as Oracle ParallelServer, work via each computer keeping copies of the database inRAM and in<strong>for</strong>ming each other of updates via high-speedcommunications networks. The machine-to-machine communicationcan be as simple as a high-speed Ethernet link or as complex asspecialized circuit boards and cables that achieve memory busspeeds.Don't we have the same problem of inter-CPU synchronization with amulti-CPU single box server? Absolutely. CPU I is serving Client A.CPU II is serving Client B. The two CPUs need to apprise each otherof database updates. They do this by writing into the multiprocessormachine's shared RAM. It turns out that the CPU-CPU bandwidthavailable on typical high-end servers circa 2002 is 100 Gbits/second,which is 100 times faster than the fastest available Gigabit Ethernet,FireWire, and other inexpensive machine-to-machine interconnectiontechnologies.Bottom line: if you need more than 1 CPU to run the RDBMS, itusually makes most sense to buy all the CPUs in one physical box.11.1.2 Abstraction LayerSuppose that you have a complex calculation that must be per<strong>for</strong>medin several different places within a computer program. Most likelyyou'd encapsulate that calculation into a procedure and then call thatprocedure from every part of the program where the calculation wasrequired. The benefits of procedural abstraction are that you onlyhave to write and debug the calculation code once and that, if therules change, you can be sure that by updating the single procedureyou've updated your entire application.The abstraction layer is sometimes referred to as "business logic".Something that is complex and fundamental to the business ought tobe separated out so that it can be used in multiple places consistentlyand updated in one place if necessary. Below is an example from anecommerce system that Eve Andersson wrote. This system offerssubstantially all of the features of amazon.com circa 1999. Eveexpected that a lot of ham-fisted programmers who adopted heropen-source creation would be updating the page scripts in order to203

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

Saved successfully!

Ooh no, something went wrong!