2003 08 05 LinuxWorld

Uploaded from authorPOINTLite
Views:
 
Category: Entertainment
     
 

Presentation Description

No description available.

Comments

Presentation Transcript

Dynamic Content Web Sites: Technologies & Scalability : 

Dynamic Content Web Sites: Technologies & Scalability Emmanuel Cecchet emmanuel.cecchet@inria.fr

Dynamic content Web site: 

Dynamic content Web site Web content is more and more dynamic

e-Commerce servers: 

e-Commerce servers Multi-tier architecture

Outline: 

Outline Technologies Performance Clustering Conclusion

PHP: 

PHP Hypertext Preprocessor Scripting language Module integrated in Web server

PHP example : 

PHP example <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <body> <h1>Region list</h1> <?php $result = mysql_query("SELECT * FROM regions", $link) or die("ERROR: Request failed"); if (mysql_num_rows($result) == 0) print("<h2>Sorry, no region, db is empty.</h2><br>"); else while ($row = mysql_fetch_array($result)) { print("<a href=\"BrowseCategories.php?region=". $row["id"]."\">".$row["name"]."</a><br>\n"); } mysql_free_result($result); ?> </body> </html>

PHP: 

PHP Pros easy to learn ideal for small projects widely used no strong typing Cons no strong typing code maintenance interpreted language executes in the Web server process ad-hoc APIs for database access

Java Servlets: 

Java Servlets Java based Executes in a “Servlet Container” JDBC: unified interface for database access

Java Servlet example: 

Java Servlet example public class BrowseRegions extends HttpServlet { … public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { out.print("<h1>Region list</h1>"); try { ResultSet rs = connection.createStatement().executeQuery("SELECT * FROM regions"); if (!rs.first()) out.print("<h2>Sorry, no region, db is empty</h2><br>"); else do { out.print("<a href=\"BrowseCategories?region="+rs.getInteger("id")+ "\">"+rs.getString("name")+"</a><br>\n"); } while (rs.next()); } catch (Exception e) { out.print("ERROR: Request failed for the following reason: " + e); return; } } }

What about JSP?: 

What about JSP? Java Server Pages Sun’s answer to Microsoft ASP “scripting for servlets” Scripting language Compiled into a Java servlet at the first execution

JSP example : 

JSP example <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <body> <h1>Region list</h1> <% try { ResultSet rs = connection.createStatement().executeQuery("SELECT * FROM regions"); if (!rs.first()) { %> <h2>Sorry, no region, db is empty</h2><br> <% } else do{ %> <a href="BrowseCategories?region=" <%= rs.getInteger("id") %> "> <%= rs.getString("name") %> </a><br> <% } while (rs.next()); } catch (Exception e) { %> ERROR: Request failed for the following reason: <%= e.getMessage() %> <% } %> </body> </html>

Servlets/JSP: 

Servlets/JSP Pros OO programming (JSP for scripting) design patterns maturity JDBC for database access Servlet container independent from Web server Cons Web server / Servlet server communication limited number of services OO programming is more verbose (servlets)

J2EE Servers : 

J2EE Servers Java 2 Enterprise Edition Separation of presentation and business logics

J2EE Servers : 

J2EE Servers Presentation logic JSP or Servlets Business logic Enterprise JavaBeans (EJB) Entity Beans database mapping BMP: by hand CMP: automatic Session Beans stateless: temporary operations stateful: temporary objects (shopping cart) Message Driven Beans asynchronous messages

J2EE: 

J2EE Pros well suited for large projects or EAI presentation and business logic isolation large number of services (transactions, security, asynchronous messaging, clustering, …) Cons requires skills large number of specs impact of design on performances complex to setup portability across servers to improve

Open-source offers: 

Open-source offers PHP implementation from php.net included in Apache Servlets Tomcat (http://jakarta.apache.org/tomcat/) Jetty (http://jetty.mortbay.com) J2EE JOnAS (http://jonas.objectweb.org) JBoss (http://jboss.org)

Outline: 

Outline Technologies Performance Clustering Conclusion

RUBiS Benchmark: 

RUBiS Benchmark online auction site modeled after eBay.com 9 open-source implementations PHP Servlets 7 EJB all results are online http://rubis.objectweb.org/

RUBiS – PHP & Servlets: 

RUBiS – PHP & Servlets Apache/PHP vs Apache/Tomcat

JVM Performance: 

JVM Performance

Design patterns: Servlets only: 

Design patterns: Servlets only Presentation and business logic mixed Database Web container Servlet Presentation logic Business logic Servlet Presentation logic Business logic

Design patterns: Session Beans: 

Design patterns: Session Beans Presentation and business logic separation Session bean EJB container Business logic Servlet Web container Servlet Database Presentation logic Presentation logic Session bean Business logic

Design pattern: Entity Beans: 

Design pattern: Entity Beans Data Access Objects separation with Entity Beans (BMP or CMP) EJB container Entity Bean Database Entity Bean Entity Bean Web container Servlet Presentation logic Business logic Servlet Presentation logic Business logic

Design patterns: Session façade: 

Design patterns: Session façade Façade session bean with EJB 1.1 EJB container Entity Bean Session facade Web container Session facade Database Entity Bean Entity Bean Business logic Business logic Servlet Servlet Presentation logic Presentation logic

Design patterns: EJB 2.0 local: 

Design patterns: EJB 2.0 local Session façade with EJB 2.0 local interface Entity Beans EJB container Entity Bean Session facade Web container Session facade Database Entity Bean Entity Bean Business logic Business logic Servlet Servlet Presentation logic Presentation logic

Code complexity: 

Code complexity

RUBiS - J2EE Servers: 

RUBiS - J2EE Servers Apache/Tomcat/JBoss vs Apache/Tomcat/JOnAS

J2EE Performance : 

J2EE Performance Session Beans = Servlets >= PHP Entity Beans BMP = CMP data access very (too?) fine grain Design pattern determines performance Communication layers : 45 to 90% cpu usage Container design Less than 2% of execution time in user bean code

Outline: 

Outline Technologies Performance Clustering Conclusion

Clustering : 

Clustering

Web site Clustering: 

Web site Clustering

Servlet/JSP Clustering: 

Servlet/JSP Clustering

EJB Clustering: 

EJB Clustering

J2EE Clustering: 

J2EE Clustering

Database clustering: 

Database clustering Performance scalability bounded by database Large SMP are not commodity Database tier must be scalable fault tolerant (high availability + failover) without modifying the client application using open source databases on commodity hardware

RAIDb: 

RAIDb Redundant Array of Inexpensive Databases (RAIDb) better performance and fault tolerance than a single database, at a low cost, by combining multiple DB instances into an array of DB. RAIDb controller gives the view of a single database to the client balances the load on the database backends RAIDb levels RAIDb-0: full partitioning RAIDb-1: full mirroring (best fault tolerance) RAIDb-2: partial replication (best performance)

C-JDBC: 

C-JDBC Middleware implementing RAIDb Two components generic JDBC 2.0 driver (C-JDBC driver) C-JDBC Controller C-JDBC Controller provides performance scalability high availability failover caching, logging, monitoring, … Supports heterogeneous databases

RAIDb with: 

RAIDb with

C-JDBC RAIDb-1 example: 

C-JDBC RAIDb-1 example no client code modification original PostgreSQL driver and RDBMS engine C-JDBC provides scalable performance and high availability

C-JDBC RAIDb-2 example: 

C-JDBC RAIDb-2 example unload a single Oracle DB with several MySQL add caching, fault tolerance, and monitoring for free

TPC-W Performance: 

TPC-W Performance

Outline: 

Outline Technologies Performance Clustering Conclusion

PHP, Servlets or J2EE ?: 

PHP, Servlets or J2EE ? PHP: Apache ideal for small projects no typing, ad-hoc APIs Servlets: Tomcat/Jetty OO programming JDBC for database access J2EE: JOnAS/JBoss for large projects business and presentation logic isolation large number of services Clustering for scalability

Slide44: 

Questions ? Apache/PHP/Tomcat: http://www.apache.org Jetty: http://jetty.mortbay.com JOnAS: http://jonas.objectweb.org/ JBoss: http://www.jboss.org RUBiS: http://www.objectweb.org/rubis LVS: http://www.linuxvirtualserver.org : http://c-jdbc.objectweb.org/

RUBiS – Overall results: 

RUBiS – Overall results