Diese Präsentation wurde erfolgreich gemeldet.
Wir verwenden Ihre LinkedIn Profilangaben und Informationen zu Ihren Aktivitäten, um Anzeigen zu personalisieren und Ihnen relevantere Inhalte anzuzeigen. Sie können Ihre Anzeigeneinstellungen jederzeit ändern.

Building and managing applications fast for IBM i

62 Aufrufe

Veröffentlicht am

PHP is the top platform for building and modernizing IBM i applications. In this webinar, Erwin discusses how features of the application server can be leveraged to streamline the development process as well as fast-tracking the management of the PHP environment.

Veröffentlicht in: Software
  • Als Erste(r) kommentieren

Building and managing applications fast for IBM i

  1. 1. 1© 2018 Rogue Wave Software, Inc. All Rights Reserved.
  2. 2. 2© 2018 Rogue Wave Software, Inc. All Rights Reserved. • Frameworks – a path to faster development • Language considerations • Run-time performance • Application development • Application deployment • Application management • Q & A
  3. 3. 3© 2018 Rogue Wave Software, Inc. All Rights Reserved. • A number of topics in this presentation are related to, or available from, Zend Server. • It is important to understand what Zend Server is • Zend Server is a complete and certified PHP distribution stack • In addition to the PHP engine, installation of Zend Server provides an application for managing various aspects of the PHP application stack including: – Monitoring – Performance – Security – Applications NOTE: This is not intended to be a Zend Server webinar; however, aspects of Zend Server as related to performance will be highlighted.
  4. 4. 4© 2018 Rogue Wave Software, Inc. All Rights Reserved. Watch the full webinar on-demand now
  5. 5. 5© 2018 Rogue Wave Software, Inc. All Rights Reserved.
  6. 6. 6© 2018 Rogue Wave Software, Inc. All Rights Reserved. • A framework can be viewed as an application model that is customized by an application developer to satisfy a particular requirement • Frameworks provide a rich set of components for commonly invoked tasks – Includes simple interfaces and logic structures for accessing those libraries • Frameworks contain source code for solving particular problems with a particular discipline – Provides a set of APIs (function calls) that an be used to ivoke specific functionality with the framework
  7. 7. 7© 2018 Rogue Wave Software, Inc. All Rights Reserved. • Frameworks help development teams to concentrate on the specific requirements that they are trying to satisfy without having to expend valuable time and energy to design and implement the low-level common functions required by the application • Development projects can be completed faster since not all of the code is being developed from scratch • Provides reusable, maintainable, and well-organized code • Frameworks offer libraries and ready-to-use components – no need to reinvent the wheel for each new project • Once a framework is mastered, applications can be developed faster because the framework provides a structured way to approach the development project • A framework provides pre-written common application logic
  8. 8. 8© 2018 Rogue Wave Software, Inc. All Rights Reserved. • Implements PSR-7 (HTTP message interfaces) – PSR stands for PHP Standard Recommendation – in the case of PSR-7, the standard defines common interfaces for representing HTTP messages and URIs for use when communicating through PHP • Expressive is a PSR-7 implementation as well as a middleware library built on top of the implementation • Expressive is an alternative to Zend Framework as it provides a departure from the HTTP abstraction present in Zend Framework • Expressive is middleware in that it is code that exists between the request and the response – Expressive provides capability to take incoming requests, perform actions based on the request, and either complete the response or pass delegation on to the next middleware in the queue
  9. 9. 9© 2018 Rogue Wave Software, Inc. All Rights Reserved. // In public/index.php: use ZendDiactorosResponse; use ZendDiactorosServer; use ZendStratigilityMiddlewareNotFoundHandler; use ZendStratigilityMiddlewarePipe; use function ZendStratigilitymiddleware; use function ZendStratigilitypath; require __DIR__ . '/../vendor/autoload.php'; $app = new MiddlewarePipe(); $server = Server::createServer([$app, 'handle'], $_SERVER, $_GET, $_POST, $_COOKIE, $_FILES); // Landing page $app->pipe(middleware(function ($req, $handler) { if (! in_array($req->getUri()->getPath(), ['/', ''], true)) { return $handler->handle($req); } $response = new Response(); $response->getBody()->write('Hello world!'); return $response; })); // Another page $app->pipe(path('/foo', middleware(function ($req, $handler) { $response = new Response(); $response->getBody()->write('FOO!'); return $response; }))); // 404 handler $app->pipe(new NotFoundHandler(function () { return new Response(); })); $server->listen(function ($req, $res) { return $res; });
  10. 10. 10© 2018 Rogue Wave Software, Inc. All Rights Reserved. • The code snipit provides two examples of middleware • The first is landing page – Listens at the root path – If the request path is empty or / then the middleware completes the response • If the request is not an empty path or a / then control is delegated to the next middleware in the stack • The second middleware matches on the path /foo (or will match /foo, or /foo/) as well as any path beneath /foo – If the path matches /foo than the response is provided as it's own message • If the path is not the root path or the /foo path than a '404 status' is composed
  11. 11. 11© 2018 Rogue Wave Software, Inc. All Rights Reserved. • Zend Framework is an implementation of the Model View Controller (MVC) architecture. • Expressive is middleware that is often simpiler to get developers up and running with. • Zend Framework requires developers to start learning about dependency injection and event system before then can even approach writing a controller. • Middleware such as Expressive can help to get develoeprs started more quickly, as an example: $app->get('/hello', function($request) { return new TextResponse('Hello, world'); })
  12. 12. 12© 2018 Rogue Wave Software, Inc. All Rights Reserved.  • Streamline SQL requests: – Request: SQL statement – Action: • Check for/establish database connection • Execute SQL statement – Response: • Success/failure indication • Data-set (if SQL statement was a select statement) • Streamline ILE artifact requests: – Request: ILE artifact – Action: • Build-up XMLToolkit call based on request type and optional data • Execute XMLToolkit via XMLService – Response: • Success/failure indication • Data set (if ILE action results in data)
  13. 13. 13© 2018 Rogue Wave Software, Inc. All Rights Reserved.
  14. 14. 14© 2018 Rogue Wave Software, Inc. All Rights Reserved. • The db2_connect() and db2_pconnect() statements are used in PHP scripts on IBM i to establish a connection to the IBM DB2 database. – The db2_pconnect() function establishes a persistent connection to database – when a db2_close() is encountered on a persistent connection, the underlying DB2 client connection remains open to serve the next matching db2_pconnect() request • The ibm_db2 extension can be configured to treat all db2_connect() calls as db2_pconnect() calls
  15. 15. 15© 2018 Rogue Wave Software, Inc. All Rights Reserved. • Optimizations to the Zend Engine significantly enhances performance • Performance gains ranging from 20-70% have been seen in real-world applications – No application code changes required!
  16. 16. 16© 2018 Rogue Wave Software, Inc. All Rights Reserved.
  17. 17. 17© 2018 Rogue Wave Software, Inc. All Rights Reserved. • Three types in PHP: – OpCache: Improves PHP performance by storing precompiled script bytecode in shared memory – this reduces the need for the PHP engine to parse scripts on each request. – Data Cache: – Page Cache: A cache is a collection of duplicate data where the original data is expensive to fetch or compute relative to the cache.
  18. 18. 18© 2018 Rogue Wave Software, Inc. All Rights Reserved. • OPcache has a number of functions for working with and managing the cache. • Two functions of particular note: – opcache_compile_file  This function can be used to compile a php script without executing it. A typical usage of this function is to prime the cache after a web server restart – opcache_is_script_cached  This function returns an indication as to whether a script is cached or not. Typically used to detect the warming of the cache for a particular script More information on the OPCache functions ccan be found on php.net http://php.net/manual/en/ref.opcache.php
  19. 19. 19© 2018 Rogue Wave Software, Inc. All Rights Reserved. • Data Cache is a component of Zend Server that provides a set of PHP functions to improve performance. • Different data types can be stored in the cache including strings, arrays, and objects. • Items can be stored in shared memory or disk • Cached objects can be grouped together in namespaces. • Data Cache is typically used when it is impracticle to cache the entire page (see page caching) – One example would be a form that includes credit card numbers, social security numbers, and other personal privileged information (PPI) that you don't want stored in a cache Information on working with the data cache can be found at: http://files.zend.com/help/Zend- Server/content/working_with_the_data_cache.htm
  20. 20. 20© 2018 Rogue Wave Software, Inc. All Rights Reserved. • Page Cache is a component of Zend Server and is used to improve application performance by caching the entire output of a PHP script – It is important to note that Page Cache does not mitigate the dynamic capability of a PHP generated page – the dynamic capability is maintained through a rules system. • Use of Page Cache does not require any change to the underlying PHP code. • As a best practice, pages should be cached when their content is stable and does not require frequent changes. More information on page cache can be found at: http://files.zend.com/help/Zend- Server/content/page_cache_concept.htm?Highlight=page%20cache
  21. 21. 21© 2018 Rogue Wave Software, Inc. All Rights Reserved. • Pages to cache are defined via rules within the page caching function:
  22. 22. 22© 2018 Rogue Wave Software, Inc. All Rights Reserved. A number of factors will affect the effectiveness of the cache including number of page request, frequency of data updates on the page, cache life, etc.
  23. 23. 23© 2018 Rogue Wave Software, Inc. All Rights Reserved. • The Dashboard provides information that can be useful both as an indication of the performance of various aspects of the application stack as well as indicating potential bottlenecks
  24. 24. 24© 2018 Rogue Wave Software, Inc. All Rights Reserved. Watch the full webinar on-demand now
  25. 25. 25© 2018 Rogue Wave Software, Inc. All Rights Reserved. • Information available on the dashboard: – Overview  shows information such as events, requests per second, and average response time. Note that the information displayed can be at the overall PHP engine level or at the application level – System Health  shows the number of events (segmented as notice, critical, and warning) as well as a breakdown of the processing to show where time is being spent (i.e., output, database, network, disk, php) – System Utilization  utilization metrics for active users, cpu usage, and average memory usage – Usage Statics  breakdown by browsers, operating system, and geographic location of requesters
  26. 26. 26© 2018 Rogue Wave Software, Inc. All Rights Reserved. • Information available on the dashboard: – Mobile Usage  breakdown of operating system distribution and mobile vs. desktop requests – Mobile Statistics  shows requests per second and processing breakdown by output, database, network, disk, and php The "Statistics Charts" page from the Zend Server documentation can be a good place to get more information on the statistical information available on the dashboard: http://files.zend.com/help/Zend- Server/content/zend_statistics_charts.htm
  27. 27. 27© 2018 Rogue Wave Software, Inc. All Rights Reserved. • The ability to monitor the PHP runtime environment, and more importantly be able to take action based on events can be instrumental to ensuring optimal performance of PHP applications • A number of monitoring related functions are available: Function Description URL Insight View detailed reports and information on specific requests for PHP pages located on the web server. Events Displays events encountered/detected by Zend Server. An event is runtime-related information collected by the Monitor component. Events are triggered based on the monitoring rules. Event Rules Used to display and generate the Event rules that trigger events.
  28. 28. 28© 2018 Rogue Wave Software, Inc. All Rights Reserved. • Event Rules are used to define: – Events to monitor – Thresholds to trigger the event – Actions to take when an event is triggered
  29. 29. 29© 2018 Rogue Wave Software, Inc. All Rights Reserved.
  30. 30. 30© 2018 Rogue Wave Software, Inc. All Rights Reserved. • Application Management in Zend Server supports a number of key functions including: – Initial Deployment – Update – Redeployment – Rollback – Removal • Application installation, whether it is performed manually or through the application packaging has three broad steps: In a clustered environment applications can be deployed to multiple nodes in the cluster at the same time!
  31. 31. 31© 2018 Rogue Wave Software, Inc. All Rights Reserved. • The ability to deploy an application (not to be confused with defining an application which I'll talk about shortly) requires an application package • The application package contains: – Data (application files, deployment scripts) – Scripts (commands/steps to follow for deployment, rollback, remove) – XML descriptor file (information needed to deploy the application using the Zend Server deployment feature)Application deployment can shorten the time it takes for actions such as the deployment, redeployment, and update of applications by streamlining the steps required and automating the process. Example: A set of PHP demo scripts that shows the db2 function calls and XMLToolkit exploitation on IBM i is delivered as a deployment package
  32. 32. 32© 2018 Rogue Wave Software, Inc. All Rights Reserved.
  33. 33. 33© 2018 Rogue Wave Software, Inc. All Rights Reserved. • Z-Ray is a development tool that provides insight into the details of a page request. • The Z-Ray toolbar is injected into the response from the PHP application and shown in the browser: • Z-Ray provides application insight without having to change the development workflow. Summary Information for Z-Ray: http://www.zend.com/en/products/s erver/z-ray
  34. 34. 34© 2018 Rogue Wave Software, Inc. All Rights Reserved. • Information available in Z-Ray includes
  35. 35. 35© 2018 Rogue Wave Software, Inc. All Rights Reserved. Backtrace information as well as IDE actions are available!
  36. 36. 36© 2018 Rogue Wave Software, Inc. All Rights Reserved.
  37. 37. 37© 2018 Rogue Wave Software, Inc. All Rights Reserved.
  38. 38. 38© 2018 Rogue Wave Software, Inc. All Rights Reserved. • While Z-Ray is most often used in development, it can also be used in production to isolate and identify run- time issues – By default Z-Ray is disabled in production – Selective mode provides for the definition of constraints for Z- Ray including time, URL, and browser address
  39. 39. 39© 2018 Rogue Wave Software, Inc. All Rights Reserved. • Imagine the following scenario: – Customer has implemented the open source moodle application • Moodle is a Learning Platform or Course Management System (CMS) • When the customer updated to the latest version of Moodle they were seeing significant performance issues (frankly, the application was unusable) • See Next Slides for how using Z-Ray quickly identified the issue:
  40. 40. 40© 2018 Rogue Wave Software, Inc. All Rights Reserved. • Step 1: Enable Z-Ray in selective mode for the application • Step 2: From a Web Browser, make a request to the moodle URL • Step 3: When the Z-Ray tool-bar is displayed review the execution time information: 34.72 ms 78% 128.64 ms 21% 2.10 ms 1% 0.00 ms ~0%
  41. 41. 41© 2018 Rogue Wave Software, Inc. All Rights Reserved. • Step 4: Review Database Queries: – Step 4a: Sort on the 'Time' field to bring the longest running database statement to the top • Sort showed that the longest running SQL statement was the database connection statement – Investigation of that issue showed A DNS issue within the customer's environment The use of Z-Ray identified the issue within a matter of minutes – the customer had previously spent days trying to isolate the issue!!
  42. 42. 42© 2018 Rogue Wave Software, Inc. All Rights Reserved. Watch the full webinar on-demand now
  43. 43. 43© 2018 Rogue Wave Software, Inc. All Rights Reserved.
  44. 44. 44© 2018 Rogue Wave Software, Inc. All Rights Reserved. zend.com/downloads Try Zend Server for IBM i
  45. 45. 45© 2018 Rogue Wave Software, Inc. All Rights Reserved.

×