Sunday, March 15, 2015

PHP: Lower the Entry Process for your website

If you have a website that is using PHP on the server side, you may be struggling with the Entry Process reaching the top limit of your web host.

What is an Entry Process?  Basically, it means that a process is launched on your web server host each time a page is requested.  If you have a lot of traffic, this means that at some point, you may reach the Entry Process Limits imposed by your web host and your visitor will get a message that too many resources are being used.

This is really annoying but there is not much that you can do about it if you are hosting static html page.  On the other hand, this issue can be triggered by your dynamic web pages and can be improved by tweaking the rendered code to be faster.


If you are using PHP, as a lot of web developers are doing, you may have a webpage that does look like this:
<?php $title = "Crombz.com - The best website!";?>
<html>
<head>
<title><?php echo $title; ?></title>
</head>
<body>
   Hello, this is my webpage and the title is <?php echo $title; ?>
</body>
</html>
This is a regular case where you will embed in the HTML code some part of PHP code.  It does work nicely but has a major drawback:  The page will be rendered a bit slower than a pure HTML page.

Since a PHP webpage takes a bit more time to be served by your host, you do increase the chance of  reaching the Entry Process Limits if you have a lot of traffic.  Assuming that you are limited to 10 Entry Processes at the same time, if the time to render your PHP page takes 0.2 seconds, you will have a maximum of 5 visitors being able to view your page at the same time.

I have struggled this week with this issue on my website Crombz.com.   After reviewing the code, I realized that PHP had to parse a mix of HTML and PHP to be able to render the page properly.  After some experimenting and tweaking, I modified my code like this:

<?php
    $title = "Crombz.com - The best website!";
?>

<html>
<head>

<?php
    echo '<title>'.$title.'</title>';
?>

</head>
<body>

<?php
   echo 'Hello, this is my webpage and the title is .$title;
?>

</body>
</html>
I made sure that a single line was either a pure HTML code or a pure PHP code...  It has lowered the rendering time so much that even with 30 visitors, I am not reaching the Entry Process Limit of my web host.

Of course, your code will be a bit more complex but the benefits are that you will lower the chance of reaching the Entry Process Limits even with a high traffic.

I haven't tested rendering a webpage in pure PHP, but it would probably be faster than having mixed lines of HTML and PHP.

Happy coding!



Thursday, March 12, 2015

Google Code is shutting down!

Today I received this email from Google. It's a sad one as Google Code will shutdown it's service in the next year.



This means I will have to move my projects to another host. Sadly, all links posted on the web will have to be redirected. I'm thinking at WebcamStudio mainly where everything was built around Google code for packaging the Debian app.

Too bad Google Code is disappearing, it was a great platform.

Patrick Balleux

Sunday, March 8, 2015

Share your website over Twitter with Cards

When sharing a link over Twitter, you may see that a summary is sometime available giving a preview of the website to the viewers.

Did you know that you can have the same result with your website? Twitter has made available metatags that you can integrate into the header of your webpage so the summary will be visible.


Ref: https://dev.twitter.com/cards/overview

Once your tags are in place, you need to validate your website with Twitter:
https://cards-dev.twitter.com/validator

I did set the tags on Crombz.com and you can see the results when Crombz.com is shared.



And if you can use some PHP, you can even create dynamic content like this:



This will make you website look better in social networks, at least on Twitter. Facebook and Google do also use some kind of metatags to achieve the same results.

Making your website ready for social networks is a must. After only a few days, I can already see Crombz.com getting more visitors and being shared over Twitter more than before.


Patrick Balleux