PHP Design
Design is just…

Background from: Adam Betts
In response to:
Design is just…
Design is more than…
Design is making fun of…
Design is more than jumping…
Design is more than just choosing…
Design is more than making clients…
Design is finding balance…
Design is owning a clipart…
Design is more than just making things pretty…
Programming is just the art of…
Design is just using swatches…
Design is more than just logos…
The Real…
For the group: Designer Wallpaper
See where this picture was taken. [?]
Facebook publishes Hip Hop PHP
Concern for performance
Rumors were already circulating in recent weeks because of an interview with an alleged employee of Facebook. In the article, the engineer mentioned the release of a version of PHP developed by Facebook itself, to provide better performance than the base implementation language. However, the official presentation of HipHop has been made that week.
The engineer responsible for HipHop, Zhao Haiping, explained that the project is several years old. Facebook is mainly written in PHP but the version of the language used is inefficient, forcing engineers to use other languages. Thus, Facebook has used or still uses technologies like Java, Python (and the server Tornado), Erlang (used for cat) or even C++. The site is therefore involved in a number of open source projects, which is sometimes the initiator, as the database Cassandra.
However, Zhao said that 90% of the site is written in PHP, because the language allows him to develop as more simply and quickly to new features, not to mention that using another technology involves writing code “glue” in PHP to use it on the site. In the development of a web project, the performance of pages are not a problem, at least initially, because the main concern is the database.
But the success of Facebook compels a heavy load (about 350 million users, or 400 billion page views per month), which requires programmers to use the techniques of caching and moves the problem toward the Page Code itself. Generally, the sites of the so called “web 2.0″ are often subjected to critical issues of performance, and official implementation of PHP has not been designed for sites undergoing such massive support.
A hyper-PHP
The engineers then had several choices: rewrite the whole site in another language (which would take time), or continue to use third-party technologies like C++ by simply writing a “glue code” in PHP to link with this code. The third possibility, that was chosen was to make PHP faster, to reduce server load while retaining ease of use of language.
Other older projects had this objective. For example, Roadsend or PHC are two compilers that generate C code from a PHP program, Quercus produces Java code, etc.. But the project team chose to launch its own compiler, which translates into is the PHP code into a C++ code, integrating a web server written for the occasion.
The fact that PHP syntactically similar to C++ allows, according to Zhao, translate directly a part of the code. However, HipHop do not stop there: the compiler must analyze the dependencies of each file to optimize the function calls or the use of variables. In addition, C++ is a static language, the type of data must be known at compile time, which is produced by type inference: the types of variables are not reported as they would in C++, but deducted from the context of use, as do languages like OCaml (as opposed, PHP determines the type of a variable and the execution of a program). It is then g++ compiler is called to convert the C++ code into a usable program.
Naturally, the dynamic features of PHP (eg the inclusion of unknown code compilation, the eval function or indirection of variables) are incompatible with this approach, but, according to the sponsors, their use is not so common that in most sites and most of the code of Facebook, for example, is compatible with HipHop without rewriting. The project is Open Source, released under the PHP license free and available on the site GitHub.
For now, HipHop works with PHP 5.2. The first team goals are the support of version 5.3, and allow to use the Apache web server rather than one that has been developed for the occasion.
An effective approach
According Haiping Zhao, HipHop PHP is at work for longer than 6 months, and reduced server load by 50%, which saves material. Naturally, it is of no use to solve problems related to a database, and not replace, within Facebook, using languages like C++ or Erlang. It has however been proven, and its open source nature allows other sites to use, even better.
Facebook’s approach, which merely provide a new implementation of PHP technology based on pre-existing (C++) is compared with that of Google, which advises some time since their engineers not to use scripting languages like Python, and announced a few months earlier language Go, one of whose goals is not dependent on any other technology, while being effective. There is no doubt that both stories will bring many lessons as Facebook and Google have in common to suggest websites whose users are in the tens of millions.
————————————————————————————————————————————————-
More technology and Internet-related articles will be publish soon
Keep in touch
Nathaniel Group, Inc. Pioneers New Light Source
PHP Design
For more information and a free technical paper, please visit www.nathaniel.com/optical.php. Nathaniel Group, Inc. (NGI) is a world leader in original equipment designer and manufacturer. Through close collaboration with its global customers, …
PHP Design question by whoevermakes: How to design a php/mysql site that will scale massively ?
Hi.
I’m going to build a high scale site in php/mysql that needs to scale horizontally.
What things should the developer do and not do when writing the code and creating the database?
Thanks.
PHP Design best answer:
Answer by NC
It depends on how you’re going to scale your database. MySQL allows two approaches. You can either do a replicated setup or use MySQL cluster.
If you end up using MySQL cluster, you don’t need to do anything special in your PHP code; from the outside, the cluster will look and feel like a single server.
If you end up going with replicated setup, you will have to make sure that your application can be configured in a way that allows to run SELECT queries on one DB server and all other queries (UPDATE, INSERT, REPLACE, DELETE, etc.), on another. The server to which you write must be the master server; reading can be done from any of the slaves.
You might also want to check out Cal Henderson’s book, “Building Scalable Web Sites”:
http://www.amazon.com/gp/product/0596102356?ie=UTF8&tag=myvirtualdisplay-20&linkCode=as2&camp=1789&creative=9325&creativeASIN=0596102356
Cal Henderson is one of the founders of Flickr, so he knows a few things about scaling Web applications and shares them generously.
design sucks ";]
your english is fine… but if you want to fix something… it should be
"My English sux
,
so if anything is wrong, let me know…"