New Webinar: Modernising Without Destabilising: How Bread Financial Is Building Confidence Through Change

Learn more

New webinar with Bread Financial

Learn more
Contact us

Blogs

Bad Code = Bad Performance Part 2

<span id="hs_cos_wrapper_name" class="hs_cos_wrapper hs_cos_wrapper_meta_field hs_cos_wrapper_type_text" style="" data-hs-cos-general-type="meta_field" data-hs-cos-type="text" >Bad Code = Bad Performance Part 2</span>

Date 20 May 2016

Author Daniel Bennett

Part 2 – Server Side Code

This is part two of the blog discussing how bad code does often lead to bad performance of web pages, and what bad coding habits can contribute to the slow performance. In part one, I discussed how a lack of parallelism in code can slow performance down, and how using Parallel.ForEach loops could address this issue in given scenarios.

In this part of the blog, I shall be looking at Over-Reliance on Server-Side Code as a contributor to bad performance. Yet again, I shall be referring to and commentating on C# examples.

Discover how the Senior Delivery Manager at easyJet reduced risk through  capacity management in our on-demand webinar

 

Over-reliance on server side code

There is often too much reliance on server-side code to perform functions which would be capable of being completed on the client-side of the page. Let’s look at an example of a simple online registration form.

 

Bad code part 2

(Source: https://en-gb.facebook.com/)

 

A number of operations are generally executed when a user completes a form:

  1. User submits the form
  2. Validate that all form fields have been completed correctly
  3. If fields are fine, add new user to database
  4. Else, inform user that form fields are invalid
  5. Redirect user to different page, or return a message

If all of the functions for the operations above are executed server-side, the time taken to get from A to E is dependent largely on the performance of the server that the web site is hosted on.

Shifting some of these operations to client-side will reduce the load on the server, and will allow the capability of the browser to be utilised. The client-side code – which will most often be written in Javascript or jQuery – will be performed from the user’s browser, rather than from the site’s server, which reduces overhead and speeds the page up.

In this simple example, we could shift a large portion of the validation and message-returning onto client-side. We could even make use of AJAX to make a call to the server-side code to add the new user to the database.

bad code part 2 code

Admittedly, for security reasons, some checks and functions do have to be performed on the server side. However, where possible, client-side code operations reduces the demand put on the server, and reduces the number of calls and operations being made/performed on the server.

Less server reliance often equals faster performance.

Stay tuned for the third part of this blog, where I shall discuss how database queries can have a big impact on web page performance, when written and structured poorly.

 

Webinar easyJet reduce risk through capacity management

Daniel Bennett
About the author

Daniel Bennett

This is Dan's second stint at Capacitas, having spent his placement year here as a Junior Analyst. He returned to the company in July 2015, where he is now a Developer within Capacitas' in-house development team.

FinOps and AI: Building the Financial Discipline for the Next Wave of Enterprise Intelligence

AI FinOps represents an evolution rather than a replacement of traditional FinOps. It extends the model into a domain where financial, technical, and product decisions are tightly interconnected.

Read insight

Confidence Under Load: How We Verified AKS Readiness for Peak

How Capacitas verified AKS readiness for peak demand by validating workload performance, autoscaling, cluster capacity, monitoring, and incident response.

Read insight

Building Cloud Resilience: Lessons from the AWS Outage

Learning from the Latest Outage. Events like this week’s AWS disruption highlight one clear truth: resilience must be designed, not assumed.

Read insight

Bringing Order to Chaos: A Practical Guide to Chaos Testing in the Cloud

In today’s cloud-native environments, resilience is not optional—it’s critical. Chaos testing has emerged as a key practice for validating system behaviour under failure conditions.

Read insight