The Wayback Machine - https://web.archive.org/web/20160322172542/http://php.sys-con.com/node/3127923

Welcome!

PHP Authors: Liz McMillan, Carmen Gonzalez, Hovhannes Avoyan, Lori MacVittie, Trevor Parsons

Related Topics: @BigDataExpo, Java IoT, Linux Containers, PHP, Agile Computing, @CloudExpo

@BigDataExpo: Article

How to Spruce Up Your Evolved PHP Application

Three performance improvement steps

Do you have a PHP application running and have to deal with inconveniences like lack of scalability, complexity of debugging, and low performance? That's bad enough! But trust me: you are not alone.

I've been developing Spelix, a system for cave management, for more than 20 years. It originated from a single user DOS application, and has now emerged into a web application with hundreds of users, used nationwide as the official cave directory in Austria.

Just as many software projects: Spelix evolved from MS DOS to PHP-powered Web 2.0 with increased demand for functionality and scalability

Recently I applied for a job at Compuware. For a presentation during my job interview I prepared a case study about how to monitor and improve performance of Spelix with dynaTrace, a tool in Compuware APM's suite. I found more hotspots than expected, and it was much easier than expected to resolve them. I also killed two birds with one stone: Spelix is really performing now and I've got a cool, new job.

Let me share with you my experiences in that process and the best practices I've applied to bring spelix.at to its current stage.

The Challenge of Software Evolution
When we start to design a new application we have the chance to consider data volume, number of users, traffic, all of these thoughts that drive us in selecting the proper architecture. But not many of us are able to follow that procedure, because we have to deal with a grown application. A system has emerged from a tiny set of tools and scripts, more and more functionality has been added over the years. Optimization processes often concentrate on the PHP core app to create performing database access, processing and content rendering, but that's not enough. Unfortunately other tiers are not included in these processes. Too often on the client side, the brush-up ends after designing a new frontend, using existing JavaScript plugins, and not thinking about application performance. But a slow database or browser code can dramatically slow down your application, even with an optimized PHP core.

In Spelix I have identified six major scopes for performance optimization:

  1. Database
  2. Server Side Data Caching
  3. Client Side Data Caching
  4. Network Traffic
  5. Browser / CDN Cache
  6. Server Side Session Handling

To be more digestible, this blog is split into two. This post focuses on the first three performance improvement steps and the next one focuses on the last three.

Step #1: Optimize Database Access
In the early stages of an application, it may not be relevant how your database access is designed. As long as the amount of data is low, a poorly designed query or missing indexes may not really affect overall response times. Therefore, database performance is rarely a topic that comes up in many cases. Once it has become an issue, it may be rather complicated to be handled. It's important to place enough value in your database design right from the start. Here are some of my lessons learned and best practices:

Interaction of Views & Indexes
I don't want to get into too much detail about creating indexes as many other articles have covered this. But it's rather important to understand when an index is not used: be careful when using views in MySQL!

When should you use views? Views are perfect to create complex queries and store them for further use. Views are commonly used to prepare data for presentation, or even for data pre-selection based on user access rights.

When should you avoid views? While a WHERE clause on a simple view may cause an index to be used, this could fail in complex view, even though the WHERE clause is on the primary key for the primary table. Once your query gets too complex, MySQL creates a temporary table for the result of the view, and then applies the query on top of the view, without any indexes to be used. Be alert when your view contains commands like GROUP_BY, ORDER_BY, or UNION. So what? My key advice on this is: when you create a view, define possible WHERE clauses and check the execution plan in the database by using the EXPLAIN command. If your WHERE clause is on a column in a table marked as select type "primary", you are on the save side to use the view. If it's "derived" or "dependent subquery", your query might not use existing indexes. It could be better to execute the query code from the application. If you have executed the SQL statements directly from your business logic, create a data access layer that contains your query code. Consider executing multiple SQL statements and merge the data in your PHP code rather than using complex joins that may spoil your indexes.

Check and Eliminate Redundant Statements
Check if your SQL executions are really necessary! You might have executed your statement in an earlier stage, is there really a requirement to run it again? Would it make sense to keep the data in your current context instead of re-requesting it? The following screenshot shows the database statements executed by the PHP Application.

A very good metric is "Executions per calling Transaction" which makes it easy to highlight statements, which are called several times, maybe too often per transaction. If that number is greater than 1, you might want to dig deeper into your code and try to optimize that. In this example "select * from sys2" reads the settings for the current user, which is not going to change permanently. There is no requirement to run this query redundantly.

What to look for? Find your query invocations in your code and avoid repetitive executions.

Optimizations? Depending on the type of information, consider caching your data in your transaction, session storage or overall server side cache, as described in the next section.

Seeing the actual SQL Statements in the context of the request makes it easier to optimize executions of database queries.

For steps 2 and 3, and for further insight, click here for the full article.

More Stories By Harald Zeitlhofer

Harald Zeitlhofer has 15+ years of experience as an architect and developer of enterprise ERP solutions and web applications with a main focus on efficient and performant business processes, usability and application design. As a Technology Strategist in Dynatrace's Centre of Excellence team he influences the Dynatrace product strategy by working closely with customers and driving their performance management and improvement at the front line. He is a frequent speaker at conferences and meetup groups around the world. Follow him @HZeitlhofer

Comments (0)

Share your thoughts on this story.

Add your comment
You must be signed in to add a comment. Sign-in | Register

In accordance with our Comment Policy, we encourage comments that are on topic, relevant and to-the-point. We will remove comments that include profanity, personal attacks, racial slurs, threats of violence, or other inappropriate material that violates our Terms and Conditions, and will block users who make repeated violations. We ask all readers to expect diversity of opinion and to treat one another with dignity and respect.


@ThingsExpo Stories
SYS-CON Events announced today that Chetu Inc., a worldwide leader in custom software solutions for niche businesses, software-defined storage and data services platform, will exhibit at SYS-CON's @ThingsExpo, which will take place on June 7-9, 2016, at the Javits Center in New York City, NY. Founded in 2000, Chetu Inc. is a global provider of customized software development solutions and IT staff augmentation services for software technology providers. By providing clients with unparalleled ni...
Electric Imp has expanded its focus to align with evolving commercial and industrial Internet of Things (IoT) opportunities. ”As our platform evolves, it is able to satisfy markets more demanding than the initial consumer segment,” said Hugo Fiennes, CEO and co-founder of Electric Imp. "Delivering over 500,000 units through our consumer device partners helped prove the scalability, reliability and usability of our platform, and now we are targeting our unique architecture at the problems facing...
@ThingsExpo has been named the ‘Top WebRTC Influencer' by iTrend. iTrend processes millions of conversations, tweets, interactions, news articles, press releases, blog posts - and extract meaning form them and analyzes mobile and desktop software platforms used to communicate, various metadata (such as geo location), and automation tools. In overall placement, @ThingsExpo ranked as the number one ‘WebRTC Influencer' followed by @DevOpsSummit at 55th.
Symantec Corp. has announced the worldwide availability of Encryption Everywhere, a website security package available through web hosting providers. Encryption Everywhere lets web hosting providers integrate encryption into every website from the moment it is created. With the new web security service, hosting providers can offer a variety of flexible options, including basic website encryption included as part of any hosted service, and a number of premium security packages with increasingly s...
Exosite has announced its Taipei Office has formally been established. Exosite’s Taiwan operations have grown from the Taichung team, primarily focused on research and development, into a full-service IoT enablement organization with development and consulting capabilities. The new Taipei office is located in the Taipei Minsheng Dunhua district, surrounded by all its hardware and channel partners. Exosite will devote its time to the Taiwan market and expand its business into the Asia-Pacific mar...
SYS-CON Events announced today that LeaseWeb USA Inc., one of the world's largest hosting brands, will exhibit at SYS-CON's 18th International Cloud Expo®, which will take place on June 7-9, 2016, at the Javits Center in New York City, NY. LeaseWeb USA Inc. was established in 2011, a separate and distinct operating entity providing services in the USA. LeaseWeb is a trusted partner to mid-market companies, helping them find the right solution to their critical cloud-hosted needs from our global...
“Today’s generation of customers are always connected and well informed, but businesses are lagging behind in terms of both understanding and engaging their customers across all their channels in ways that are both relevant and consistent,” said Brian Walker, chief strategy officer, SAP Hybris. Only one in four companies are enabling omnichannel customer engagement, whereby they have a unified, “single view” of the customer and are delivering a consistent, contextual, and relevant experience a...
Zones, Inc., illustrated how technology solutions can improve patient care at the HIMSS16 Conference and Exhibition. Zones’ healthcare experts showcased technology to enhance patient care, ensure access to electronic medical and health records (EMR/EHR), design and implement mobility initiatives, and safeguard network and data security. Supporting every aspect of IT in the healthcare environment, Zones’ healthcare team can recommend the most productive and scalable IT solutions to ensure a high...
SYS-CON Events announced today BZ Media LLC has been named “Media Sponsor” of SYS-CON's 19th International Cloud Expo, which will take place on November 1–3, 2016, at the Santa Clara Convention Center in Santa Clara, CA. BZ Media LLC is a high-tech media company that produces technical conferences and expositions, and publishes a magazine, newsletters and websites in the software development, SharePoint, mobile development and Commercial Drone markets.
*This is part of a series of blogs examining Sensor-2-Server (S2S) communications, development, security and implementation. For the past two weeks, we’ve taken an in-depth look at what Sensor-2-Server communications are, how to implement these systems, and some of the specific aspects of communication that these systems facilitate. This week, for our final installment, we’ll examine some of the benefits, as well as security considerations, for S2S communications.
As devices, sensors, objects and people are given digital identities that connect them to the Internet by the billions, the need for security and privacy becomes a critical factor for both market adoption and safety. The 40-year-old security methods we now use on our PCs and networks cannot address many of these IoT devices.
Two-thirds of organizations implementing hybrid cloud report they’re already gaining competitive advantage from their hybrid environments and are nearly three times as likely to use it to assemble data assets or monetize data, according to findings released by IBM (NYSE: IBM). With a hybrid cloud approach, organizations can be selective about when to use cloud and when to use traditional IT infrastructure – delivering the best functionality while meeting speed and flexibility needs, as well a...
Internet of Things (IoT) platforms have evolved. Advances in technology make it possible for facilities to become more data-driven by connecting to energy assets, thereby improving building resiliency and reducing energy costs. By creating an Energy Network of Things, facilities can manage energy assets in real-time, institute system-wide operational oversight and compliance, execute energy efficiency programs, utilize real-time data, and support budgeting and asset planning across local and geo...
SYS-CON Events announced today CrowdReviews.com has been named “Media Sponsor” of SYS-CON's 18th International Cloud Expo, which will take place on June 7–9, 2016, at the Javits Center in New York City, NY. CrowdReviews.com is the first buyer’s guide that ranks products and services based on client reviews.
For basic one-to-one voice or video calling solutions, WebRTC has proven to be a very powerful technology. Although WebRTC’s core functionality is to provide secure, real-time p2p media streaming, leveraging native platform features and server-side components brings up new communication capabilities for web and native mobile applications, allowing for advanced multi-user use cases such as video broadcasting, conferencing, and media recording.
SYS-CON Events announced today Object Management Group® has been named “Media Sponsor” of SYS-CON's 18th International Cloud Expo, which will take place on June 7–9, 2016, at the Javits Center in New York City, NY, and the 19th International Cloud Expo, which will take place on November 1–3, 2016, at the Santa Clara Convention Center in Santa Clara, CA.
SYS-CON Events announced today that Pythian, a global IT services company specializing in helping companies adopt disruptive technologies to optimize revenue-generating systems, has been named "Bronze Sponsor" of SYS-CON's 18th Cloud Expo, which will take place on June 7-9, 2015 at the Javits Center in New York, New York. Pythian, a 400-person global IT services company that helps companies compete by adopting disruptive technologies, announced today that CEO Paul Vallée has been named “Diversi...
transform operational efficiency and safety for businesses and communities, especially during critical situations. During these critical events, man-made incidents or natural disasters, identifying and reaching employees with reliable and automated communications can not only protect business assets, but can be the difference between life and death. In his session at @ThingsExpo, Imad Mouline, chief technology officer for Everbridge, will highlight incident communications best practices and ...
Big Data, cloud, analytics, contextual information, wearable tech, sensors, mobility, and WebRTC: together, these advances have created a perfect storm of technologies that are disrupting and transforming classic communications models and ecosystems. In his session at @ThingsExpo, Erik Perotti, Senior Manager of New Ventures on Plantronics’ Innovation team, will provide an overview of this technological shift, including associated business and consumer communications impacts, and opportunities...
SYS-CON Events announced today that iDevices®, the preeminent brand in the connected home industry, will exhibit at SYS-CON's 18th International Cloud Expo® | @ThingsExpo, which will take place on June 7-9, 2016, at the Javits Center in New York City, NY. iDevices has announced that it has entered into a definitive agreement to sell the world’s #1 app-enabled grilling and cooking thermometer brands, namely iGrill® and Kitchen Thermometer, to Weber-Stephens Products, LLC. Weber®, the world’s lar...
Latest Stories
Cloud Expo & DevOps Summit 2015 West
KEYNOTES
Intellyx
Opening Keynote | Innovation in the Age of Digital Transformation
IBM
Day 2 Keynote | Geek Girls Are Chic: 5 Career Hacks
Octoblu
Day 3 Keynote | How We Built and Scaled an IoT Platform and Business
POWER PANELS
Cloud Expo Power Panel
Cloud Expo Power Panel | Cloud Computing: We Now Live in an API World
DevOps Summit Power Panel
DevOps Summit Power Panel | DevOps Five Years Later: What Does the Future Hold?
IoT Power Panel
@ThingsExpo Power Panel | The World's Many IoTs: Which Are the Most Important?
Cloud Expo & DevOps Summit 2015 East
KEYNOTES
IBM
Opening Keynote | Geek Girls Are Chic: 5 Career Hacks
Cisco
Day 2 Keynote | The Internet of Everything: Seizing the Opportunities
Virtustream
Day 3 Keynote at 16th Cloud Expo | Rodney Rogers, CEO of Virtustream
VENDOR PRESENTATIONS
Akana
General Session at 16th Cloud Expo | Laura Heritage, Director of API Strategy at Akana
CenturyLink
General Session at 16th Cloud Expo | David Shacochis, Vice President at CenturyLink
Cisco
General Session at 16th Cloud Expo | Paul Maravei, Regional Sales Manager, Hybrid Cloud, Cisco
CodeFutures
General Session at 16th Cloud Expo | Dan Lynn, CEO of CodeFutures Corporation
MetraTech, now part of Ericsson
General Session at 16th Cloud Expo | Esmeralda Swartz, VP, Marketing Enterprise & Cloud at Ericsson
SoftLayer
General Session at 16th Cloud Expo | Phil Jackson, Lead Technology Evangelist at SoftLayer
MetraTech, now part of Ericsson
General Session at 16th Cloud Expo | Esmeralda Swartz, VP, Marketing Enterprise & Cloud at Ericsson
Windstream
General Session at 16th Cloud Expo | Michael Piccininni, EMC, & Mike Dietze, Windstream
POWER PANELS
Cloud Expo Power Panel
Cloud Expo Power Panel | The Evolving Cloud: Where Are We Today?
DevOps Summit Power Panel
DevOps Summit Power Panel | Balancing the Three Pillars of DevOps
IoT Power Panel
@ThingsExpo Power Panel | The Internet of Things: A New Age
Microservices & IoT Power Panel
Microservices & IoT Power Panel at DevOps Summit
VIEW KEYNOTE WEBCASTS
Microsoft
Microsoft Opening Keynote | NoOps != No Operations
Qubell
DevOps Summit Keynote | Purpose-Defined Computing: The Next Frontier in Automation
PLATINUM SPONSORS
Verizon Enterprise
General Session | Verizon Pay-As-You-Go Model for Oracle Database Licenses Means Costs Savings and Business Benefits
Verizon Digital Media Services
Creating a Faster, More Secure Cloud
GOLD SPONSORS
Cisco
General Session | [Podcast] Hybrid Cloud – Different Clouds for Different Needs
SAP
General Session | Innovation with Cloud and Big Data Solutions That Will Revolutionize Your Business – Join SAP and Partners
SoftLayer
General Session | How to Architect and Optimize Your Cloud for Consistent Performance
Power Panels