Multitier Architecture Overview

Multitier Architecture Overview
Slide Note
Embed
Share

In software engineering, multitier architecture, also known as n-tier architecture, separates presentation, application processing, and data management functions. Three-tier architecture is the most common form, providing flexibility for developers to modify specific layers. Advantages include improved manageability, specialized expertise per layer, and independent evolution of tools and technologies. This article explores the web-oriented 3-tier architecture and its components such as the presentation tier, logical tier, and data tier.

  • Software Engineering
  • Multitier Architecture
  • Three-tier
  • Web-oriented Architecture
  • PHP & MySQL

Uploaded on Mar 09, 2025 | 0 Views


Download Presentation

Please find below an Image/Link to download the presentation.

The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author.If you encounter any issues during the download, it is possible that the publisher has removed the file from their server.

You are allowed to download the files provided on this website for personal or commercial use, subject to the condition that they are used lawfully. All files are the property of their respective owners.

The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author.

E N D

Presentation Transcript


  1. UFCFV4-30-2 : Data, Schemas and Applications Lecture 13 Multitier Architecture, PHP & MySQL

  2. Multitier architecture : In software engineering, multi-tier architecture (often referred to as n-tier architecture) is a client server architecture in which presentation, application processing, and data management functions are logically separated. For example, an application that uses middleware to service data requests between a user and a database employs multi-tier architecture. The most widespread use of multi-tier architecture is the three-tier architecture. N-tier application architecture provides a model by which developers can create flexible and reusable applications. By segregating an application into tiers, developers acquire the option of modifying or adding a specific layer, instead of reworking the entire application. Three-tier architectures typically comprise a presentation tier, a business or data access [logic] tier, and a data tier. (Wikipedia : Multitier Architecture)

  3. 3-tier architecture (application view)

  4. Advantages of the 3-tier architecture approach : o the ability to separate logical components of an application ensures that applications are easy to manage and understand. i.e. experts can be employed that specialise in one of the layers e.g. user interface design o because communication can be controlled between each logical tier of an application, changes in one tier, for example, the database access tier, do not have to affect the client component i.e. a change from one DBMS to another would only require a change to the component in the data access layer with little or no effect on the business/logic (middle) or UI layer. o specific tools and technologies suited to each layer can be deployed (and may evolve at a different pace) .

  5. Web-oriented 3-tier architecture (generic view)

  6. Traditional 3-tier Web-Oriented Architecture (php example) Web Services

  7. Web-oriented 3-tier architecture: tools & technologies oPresentation tier Browser / custom client, Client Side Scripting (JavaScript, (ActionScript, VBScript etc.)), Applets. o Logical Tier Web Server (Apache, IIS, Websphere etc.); Scripting Languages (PHP, Perl etc.), Programming Languages (Java, C, C# etc), Application Frameworks (Ruby on Rails etc.) oData Tier Database Management System (DBMS) (Oracle, MySQL, SQL Server, DB2 etc.), XMLDB

  8. Web Application Architecture (again) mple)

  9. Web Application Architecture Components mple)

  10. Web Application Architecture Components o 1. DNS: DNS or Domain Name System is a fundamental system that helps search a domain name and IP address, and in this manner, a particular server receives a request sent by a user. We can say that DNS is like a phonebook but for the Internet websites. mple) o 2. Load Balancer: Load Balancer primarily deals with horizontal scaling. With directing incoming requests to one of the multiple servers, the load balancer sends an answer to a user. Usually, web application servers exist in the form of multiple copies mirroring each other. Hence, any server processes requests in the same manner, and the load balancer distributes tasks among them so they will not be overcharged. o 3. Web App Servers: This component processes a user s request and sends documents (JSON, XMK, etc.) back to a browser. To perform this task, it usually refers to back-end infrastructures such as database, cache server, job queue, and others. Besides, at least two servers, connected to the load balancer, manage to process the user s requests.

  11. Web Application Architecture Components o 4. Databases: The name of this web application component speaks for itself. The database gives instruments for organizing, adding, searching, updating, deleting, and performing computations. In most cases, web application servers directly interact with the job servers. mple) o 5. Caching Service: Caching service provides storage for data, which allows storing and searching data. Whenever a user gets some information from the server, the results of this operation goes to cache. So, future requests return faster. In one word, caching allows you to refer to the previous result to make a computation much faster. Therefore, caching is effective when: the computation is slow; computation is likely to occur many times; when the results are the same for a particular request.

  12. Web Application Architecture Components o 6. Job Queue (optional) : Job queue consists of two components: the job queue itself and servers. These servers process jobs in the queue. It happens that most of the web-servers need to operate a vast amount of jobs that are not of primary importance. Therefore, when a job needs to be fulfilled, it goes to the job queue and is operated due to a schedule. mple) o 7. Full-Text Search Service (optional): Many web applications support the search by text function or so-called request, and then, an app sends the most relevant results to a user. This technology is named full-text search service. With the help of keywords, it searches the needed data among a vast number of documents. o 8. Services: When a web application reaches a specific level, services are created in the form of separate apps. They are not that visible among other web application components, but the web application and other services interact with them.

  13. Web Application Architecture Components o 9. Data Warehouse: Almost every modern application implies the work with data such as collecting, storing and analysing. These processes require three stages: 1.The data is sent to the data firehose , which provides a streaming interface for absorption and processing of data. 2.Raw, processed, and additional data is sent to cloud storage. 3.And processed and additional data also go to a data warehouse. It s a particular model of online storage and exchange of data through the Internet. The Data Warehouse can be used for storing a variety of files of different types such as videos, photos, or so on. mple) o 10. CDN: CDN or Content Delivery System deals with sending HTML files, CSS files, JavaScript files, and images. It delivers the content of the end server throughout the world, so people can load various sources.

  14. Web-oriented 3-tier architecture: assignment view

  15. MySQL in the persistence / data tier : MySQL o Open Source (relational) database server - Runs on many platforms (Unix & Windows) o Networked server no fancy GUI like MS Access. - You can find clients(such as phpMyAdmin)that provide a GUI. o Great for small, medium to large-sized applications (ebay, amazon, facebook etc. all make use of it)

  16. MySQL in the persistence /data tier : MySQL Strengths o High performance benchmarks very well against commercial dbs o Low-cost no cost under open source licence o Easy to configure and learn easy to set up, SQL compliant o Portable Linux, Unix and Windows versions o Open Source source code is available for modification

  17. phpMyAdmin o A MySQL client written in PHP o Via a browser you can : o Manage Databases o Manage MySQL users o Create tables, add/edit/delete data, browse data o Submit queries (SQL) o Import and Export tables o A great way to learn SQL!

  18. phpMyAdmin interface: phpmyadmin help mysql help manage users db status pop-up sql window home import data export db databases

  19. PHP (main) API's for using MySQL There are three main PHP API options when considering connecting to a MySQL database server: oPHP's MySQL Extension - original extension which provides a procedural interface and is intended for use only with MySQL versions older than 4.1.3. Can be used with versions of MySQL 4.1.3 or newer, but not all of the latest MySQL server features will be available. o PHP's mysqli Extension - MySQL improved extension takes advantage of new features found in MySQL versions 4.1.3 and newer. The mysqliextension is included with PHP versions 5 and later. o PHP Data Objects (PDO) - PHP Data Objects, or PDO, is a database abstraction layer that provides a consistent API regardless of the type of database server. In theory, it allows for the switch of the database server, from say Firebird to MySQL, with only minor changes to the PHP code.

  20. Advantages of the MySQLi API o Object-oriented interface o Support for Prepared Statements o Support for Multiple Statements o Support for Transactions o Enhanced debugging capabilities o Embedded server support Note: If using MySQL versions 4.1.3 or later it is strongly recommended that the mysqli extension is used.

  21. example MySQL db Entity model Example records

  22. php script using mysqli (select example) <?php // Connect to the db $mysqli = new mysqli('hostname','username','password','database'); // Send the query to the database and pull the records in a // certain city using the SELECT statement // If the result returns true if ($result = $mysqli->query("SELECT name, wp_link FROM station // print out the number of records retrieved echo 'For the city of "Bristol", there are ' .$result->num_rows.' records.<br/>'; WHERE city='Bristol'")) { // The "fetch_object()" method allows access to the returned // rows within the resource object ($result in this case). while ($row = $result->fetch_object()) { echo 'Station: '.$row->name.' '; echo 'Wikipedia Link: <a href='.$row->wp_link.'>'.$row->wp_link. '</a><br/>'; } } else { // it's an error & the query failed echo $mysqli->error; } // end else $mysqli->close(); ?> run example

  23. refactoring repeating data to another table Entity model

  24. refactored data table: station1 table: city

  25. reformulated sql query with join field name disambiguation SELECT station1.name, station1.wp_link FROM station1, city WHERE station1.city_code = city.code AND city.name = 'Bristol' tables join condition

  26. php script with sql join <?php // Connect to the db $mysqli = new mysqli(('hostname','username','password','database'); // Send the query to the database and pull the records in a // certain city using the SELECT statement // If the result returns true if ($result = $mysqli->query("SELECT station1.name, station1.wp_link FROM station1, city WHERE station1.city_code = city.code AND city.name = 'Bristol'")) { // print out the number of records retrieved echo 'For the city of "Bristol", there are ' .$result->num_rows.' records.<br/>'; } else { // it's an error & the query failed echo $mysqli->error; } // end else $mysqli->close(); ?> // The "fetch_object()" method allows access to the returned // rows within the resource object ($result in this case). while ($row = $result->fetch_object()) { echo 'Station: '.$row->name.' '; echo 'Wikipedia Link: <a href='.$row->wp_link.'>'.$row->wp_link. '</a><br/>'; } run example

  27. PHP Data Objects (PDO) o The PHP Data Objects (PDO) extension defines a lightweight, consistent interface for accessing databases in PHP. Each database driver that implements the PDO interface can expose database-specific features as regular extension functions. o PDO provides a data-access abstraction layer, which means that, regardless of which database you're using, you use the same functions to issue queries and fetch data. PDO does not provide a database abstraction; it doesn't rewrite SQL or emulate missing features.

  28. PHP Data Objects (PDO): Advantages o Database Portability (loose coupling) - (PDO's) ensure database portability. This results in adaptability and cost-effective scalability. o Better Security - PHP's MySQL extensions required the programmer to manually sanitize queries to avoid SQL injections (a way of attacking a data-driven applications by inserting malicious SQL statements into an form entry field). PDO however secures use inputs, increasing website security and reducing programmer workloads. o Improved Performance - PDO takes advantage of PHP 5 s object-oriented features, resulting in more powerful and efficient database communication. PDO is written in C and compiled into PHP providing a performance increase over solutions written in PHP. o Enhanced Reliability - PDO can use Exceptions to handle errors. For error handling PDO can wrap code in a try / catch block. PDO supports three error modes - 'silent', 'warning' and 'exception'. With clever usage, errors can be avoided or caught and handled gracefully.

  29. PHP Data Objects (PDO): Drivers Driver name Supported databases PDO_CUBRID Cubrid PDO_DBLIB FreeTDS / Microsoft SQL Server / Sybase PDO_FIREBIRD Firebird PDO_IBM IBM DB2 PDO_INFORMIX IBM Informix Dynamic Server PDO_MYSQL MySQL 3.x/4.x/5.x PDO_OCI Oracle Call Interface PDO_ODBC ODBC v3 (IBM DB2, unixODBC and win32 ODBC) PDO_PGSQL PostgreSQL PDO_SQLITE SQLite 3 and SQLite 2 PDO_SQLSRV Microsoft SQL Server / SQL Azure PDO_4D 4D

  30. example script using pdo with try{}catch{}block run example run example (with error)

  31. actual catch{}block

More Related Content