Device detection allows a website to know what mobile device is currently being used to browse it. This allows developers to specifically tailor a web page to accommodate different device types. There are two technical approaches that can be used to detect mobile devices: On-Premise and Cloud based. This blog explains the advantages and disadvantages of each and provides free source code to enable you to evaluate which solution is right for your organisation.
|Total Detection Time||23ms or less||>200ms|
|Maintenance||Automatic (with 51Degrees.mobi)||3rd Party|
|Cost||Free Unlimited Detections||Free for 5,000 detections (ScientiaMobile)|
|Availability||100% (Same as web server)||Variable|
An On-Premise solution refers to a solution that runs on the local web server. All the required data is held locally and the detection rates can be extremely fast, though some memory and CPU overheads are incurred. Some on-premise solutions will also require the user to manually maintain and update the device data but overall On-Premise device detection offers an affordable, high performance and responsive way of detecting mobile devices for your website.
Cloud Based Solution
The “Cloud” is a term used to describe any service that is computed remotely and passed back over the internet to the local web server. A Cloud device detection solution works by sending data about the requesting device to a remote server. This server then determines the device type and sends the result back over the internet to be used to offer the mobile web user a more enriched experience.
The following diagram explains the process:
The obvious advantage of the Cloud approach lies within the remote computer processing all the calculations. This relieves any overhead on the local web server; however, as detection information is passed across the internet there will always be travel time added to the total detection speed. This added distance will penalise your mobile web users, causing their experience to be far more sluggish. Updating the Cloud service is normally not a problem as a reputable service provider will be responsible for updates. The service provider will of course charge for their service, usually basing charges on the number of detections performed.
If the connection between your web server and cloud solution are slow, then your web site will slow down. If internet connection between your server and the cloud are lost at any point (if the cloud service is unreliable and drops), then you are left without a detection solution which would stop the web server operating correctly.
To compare these two approaches a simple test was created that reviews the time it takes to detect if a device is mobile and to retrieve a result from the 51Degrees.mobi PHP device detection solution running on both a local On-Premise server and on a cloud. Both solutions ran on the my.PHPcloud.com hosting service, with the cloud installation running on an Amazon high-CPU, extra-large, ec2 Instance named: c1.xlarge.
Below are the following results of the test:
|"is mobile" Detection Request||Detection Time(ms)||Cloud Detection Time(ms)||Cloud Total Detection(ms)||Cloud Travel Time(ms)|
As you can see the results show that although both servers managed to detect the devices in very similar times (22.81ms VS 17.32ms), the total detection time is far greater for the cloud. This is solely due to the amount of time that it takes for the data to be transferred across to the cloud and back (Cloud Travel Time). When you compare the overall time for a device to be detected between the two approaches (210.05 VS 22.81), you can easily see that using an on-premise solution is a far speedier option, being able to detect over 9 times faster than the cloud approach. Even if the cloud service took 0ms to calculate the result the overall detection time would be far slower than the on-premise detection.
So, is there a use for the cloud?
With 51Degrees.mobi solution available for PHP, Java, .NET and C supporting the majority of web sites there's no need to accept slower performance, increased complexity, and risk reduced availability using a cloud service. We also offer a hybrid of providing an on-premise solution that uses the cloud to periodically update the local device data repository. This method gives you the best of both worlds: The performance of an on-premise solution and the automatically updated device data that the cloud can offer.