1 / 45

Dynamic Content Web Sites: Technologies & Scalability

Dynamic Content Web Sites: Technologies & Scalability. Emmanuel Cecchet emmanuel.cecchet@inria.fr. Dynamic content Web site. Web content is more and more dynamic. e-Commerce servers. Multi-tier architecture. Outline. Technologies Performance Clustering Conclusion. PHP.

Download Presentation

Dynamic Content Web Sites: Technologies & Scalability

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


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

  2. Dynamic content Web site • Web content is more and more dynamic

  3. e-Commerce servers • Multi-tier architecture

  4. Outline • Technologies • Performance • Clustering • Conclusion

  5. PHP • Hypertext Preprocessor • Scripting language • Module integrated in Web server

  6. 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>

  7. 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

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

  9. 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; } } }

  10. 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

  11. 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>

  12. 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)

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

  14. 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

  15. 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

  16. 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)

  17. Outline • Technologies • Performance • Clustering • Conclusion

  18. 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/

  19. RUBiS – PHP & Servlets • Apache/PHP vs Apache/Tomcat

  20. JVM Performance

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

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

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

  24. Remote interface Communication layer Design patterns: Session façade • Façade session bean with EJB 1.1 Servlet Session facade Entity Presentation Business Bean logic logic Entity Session facade Bean Servlet Business Presentation Database Entity logic logic Bean Web container EJB container

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

  26. Code complexity

  27. RUBiS - J2EE Servers • Apache/Tomcat/JBoss vs Apache/Tomcat/JOnAS

  28. 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% cpuusage • Container design • Less than 2% of execution time in user bean code

  29. Outline • Technologies • Performance • Clustering • Conclusion

  30. Clustering

  31. Web site Clustering • Load balancing on Web Servers • hardware: L4-switch • software • One-IP techniques • LVS (http://www.linuxvirtualserver.org/) • RR-DNS

  32. Servlet/JSP Clustering • Web server to Servlet server • Load balancing with JK module (mod_jk) • Static weighted round-robin • Session affinity • Servlet/JSP server clustering • Tomcat in-memory session replication • failover ensured by mod_jk

  33. EJB Clustering • Servlet/JSP to EJB server • clustered JNDI • load-balancing and failover by cluster-aware stubs • EJB Server clustering • cluster stubs for load-balancing • transparent failover for idempotent methods • bean state persisted in database

  34. J2EE Clustering • Database clustering • Commercial offers • Oracle RAC (60.000$ / cpu) • based on expensive SAN (Storage Area Network) • Open-source solutions • No real clustering • master/slave replication in MySQL • Postgres-R (still in alpha)

  35. 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

  36. 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)

  37. 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

  38. RAIDb with

  39. C-JDBC RAIDb-1 example • no client codemodification • original PostgreSQLdriver and RDBMSengine • C-JDBC providesscalable performanceand high availability

  40. C-JDBC RAIDb-2 example • unload a singleOracle DB withseveral MySQL • add caching,fault tolerance,and monitoringfor free

  41. TPC-W Performance

  42. Outline • Technologies • Performance • Clustering • Conclusion

  43. 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

  44. 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/

  45. RUBiS – Overall results

More Related