


Since JSP is suitable for large websites, why is Baidu's homepage still written in PHP?
In general, Java far exceeds PHP in terms of technology. Regardless of the cost issue (which should be affordable by large companies), why is Baidu’s homepage not written in JSP? Doesn’t real-time search need to be distributed? And some results will be automatically loaded when typing.
Reply content:
Can you send this book out?
I want to block this publisher.
laxative.
First of all, let’s see if the Baidu homepage really uses php. http://www.baidu,com/index.php is undoubtedly open, but we also know that it can be opened. By setting the routing settings at the HTTP service software level, this address is actually parsed to other content, such as static files or other CGI-processed resources. For example, pseudo-static implementation is to route html to other dynamic resources, such as php (taking into account caching , it may also be a static resource), so it is impossible to determine whether it is PHP based on this alone.
So use chrome to open Baidu,
The information we need to see is the content boxed in red. First we see that the value of Sever is set to bfe/1.0.8.14, the server field in the http header Usually it is the name of the http server, such as Zhihu:
Qnginx. I guess it may be a magic modification of Nginx. Baidu's bfe is either its own product, or it may have changed the source code of nginx or the like. For this, see What server is used on Baidu's homepage?
Then let’s take a look at the cookie content set in setcookie. We know that generally the cookies set by php itself will have fields similar to the following:
However, let’s take a look at Baidu’s:
There are many Token fields named after Baidu, and there are no cookies that come with php, nor It doesn't look like the cookies that come with many languages/frameworks, which will be discussed later.
Let’s take another look at a field in the request on Baidu’s homepage:
HPHP, which is HHVM. If Baidu doesn’t use a proxy
or modify the header or HHVM at the HTTP server level (Baidu probably won’t either If you are so free to change something that is not confidential), then you should use PHP. So let’s explain why we don’t use the default one (the default cookie will have the PHPSESSID field)
session_start()
Facebook is still written in PHp, as are Sina Weibo and Tencent. Do you still use Python on Zhihu?
Regardless of whether the information in the title post is accurate or not
The PHP on Baidu’s homepage is just for rendering results. The search engine itself should not be based on PHP.
Holy crap. .
As a Baidu employee, I saw this question in the middle of the night and instantly became energetic. .
One is smiling, and the other is unable to help but complain deeply deep in his heart. .
Are you a student? Or that I have never been exposed to very large projects. If you have the opportunity to go to a big company and get in touch, you will understand that this question is really stupid. .
The company has been attracting bad guys lately, so I’ll stay anonymous because I’m too lazy to argue with people.
First of all, PHP can do page rendering, but if you have ever worked on a framework, you should know that this URL request will be distributed, and there is a lot of room for independent operation wherever it is distributed.
First of all, intermediate distribution is definitely not as simple as you think. There are hundreds of millions of requests every day, and there will definitely be various caches, clusters distributed across the country, etc.
Besides, in order to speed up the loading speed of the home page, it must be changed to C optimization.
Then, when you enter, it will be distributed to the corresponding retrieval cluster.
The code for this is C++, why? Because I changed it myself. .
This is divided into many modules. .
For example, the process from when you input a word into the search box to when the data is retrieved is indeed very simple. .
The crawler crawls the data and then builds an index based on the data.
The problem is that it’s very complicated to do the best in every detail.
How can you be more accurate when segmenting words? Directly use an open source library? Are you kidding me? It is best to have a professional team in charge of this, and it is more research-oriented, so we need to recruit a lot of PhDs and graduate students to do it.
Okay, now that the words have been divided, we need to get the index.
How to find the corresponding data among hundreds of billions of results within milliseconds?
Then sort them and return the results the user wants? Sound complicated?
Actually, it’s not troublesome to say this. Just zip it upside down and make a good cache. In fact, 90% of the searches are 10% of the words.
However, the amount of data is a bit large, so the entire index may not be placed in the memory, and part of it must be placed on the hard disk. The problem is that the hard disk is slow. Can we do some optimization?
Then how to choose the most suitable one for users? There are many optimization points in this strategy, and if you do it well, you will gain a group of people.
This is just retrieval.
In terms of crawlers, the data we crawl down every day is beyond ordinary people’s imagination. How to crawl efficiently can provide more reliable data to the retrieval end.
This is done by a bunch of people again.
But the problem comes again, you find that the amount of data is too large, how to save this data? How to manage better?
This doesn’t all require a lot of manpower to do. .
Oh, and Fengchao, this one is hacked by you every day.
Because it involves money, a lot of manpower is invested in various strategies and data optimization.
So, I saw your question. . . .
I really think, what the hell, let’s get into the next super-large project.
You will find that basically there is a language that is most suitable for you at a certain moment, so just use it.
Baidu only has a few people at the beginning, and it will be good if it has hundreds of thousands of users. Just go to a website and use it quickly, and there is no need to consider efficiency. Back-end indexing, when there was no Hadoop at the beginning, there were always problems with machine maintenance, so I sent a few people to do manual maintenance every day.
Then, later I found that php was not easy to use, so I thought about optimization.
Anyway, once the business is established and the money is made, if a bunch of talented people work hard, they will definitely be able to come up with a solution.
Of course, search engines are still very technically demanding. Now that various frameworks and cloud computing have matured, they are much easier to do. In the past, there were indeed huge technical barriers to doing so.
At least dozens of times more difficult than setting up a website.
But language is definitely not the biggest problem. .
You will find that you are still struggling with language here. Isn’t it stupid?
The database interface provided by php is not uniform. . . . . . How many years ago. . . It was solved as soon as pdo came out. Many of the opinions expressed by the question author are one-sided and outdated. Generally speaking, PHP is now the dominant player in the WEB business. Although jsp has advantages in large-scale businesses, in general, php can already compete with it in many aspects. . besides. . . Who told you that Baidu’s search engine is PHP. . .
The homepage is just a layer of skin, no matter what you use to write on it, there won’t be much difference. Of course, search is distributed, but it is provided as a service and has nothing to do with the homepage. As for automatically loading some results, JS sends a request, and the background is also provided as a service. As for the backend services, I don’t know how Baidu implements them. There are various languages and solutions to choose from, just choose the one that suits you. There are indeed many search solutions based on Java, but it does not mean that it cannot be done without Java. There is no upgrade or replacement relationship between php and jsp. It can only be said that each has its own strengths. The reason why php seems weak is that most people who write php in China are weak. Even if Facebook switches to PHP before hhvm, it can easily support 1 billion+ requests every day, and not many servers are used. There is no specific data, but some people speculate that the php stand-alone qps of fb at that time was around 3000-5000, which was not an order of magnitude different from the jsp stand-alone. The peak performance of a single PHP server in a company I work for is around 700 qps. This is mainly due to the confusing code writing and poor performance. Taobao's sharing shows that the single-machine QPS in some PHP business clusters is only 200-300. This can only mean that it is a human problem. Finally, it is recommended to read more articles on architecture. The answers to such questions are naturally contained in them.
Do you think Baidu search engine only has one homepage?
PHP is the most beautiful language in the world
Oh my god~
The above is that since JSP is suitable for large websites, why is Baidu’s homepage still written in PHP? For more related content, please pay attention to the PHP Chinese website (www.php.cn)!

PHP type prompts to improve code quality and readability. 1) Scalar type tips: Since PHP7.0, basic data types are allowed to be specified in function parameters, such as int, float, etc. 2) Return type prompt: Ensure the consistency of the function return value type. 3) Union type prompt: Since PHP8.0, multiple types are allowed to be specified in function parameters or return values. 4) Nullable type prompt: Allows to include null values and handle functions that may return null values.

In PHP, use the clone keyword to create a copy of the object and customize the cloning behavior through the \_\_clone magic method. 1. Use the clone keyword to make a shallow copy, cloning the object's properties but not the object's properties. 2. The \_\_clone method can deeply copy nested objects to avoid shallow copying problems. 3. Pay attention to avoid circular references and performance problems in cloning, and optimize cloning operations to improve efficiency.

PHP is suitable for web development and content management systems, and Python is suitable for data science, machine learning and automation scripts. 1.PHP performs well in building fast and scalable websites and applications and is commonly used in CMS such as WordPress. 2. Python has performed outstandingly in the fields of data science and machine learning, with rich libraries such as NumPy and TensorFlow.

Key players in HTTP cache headers include Cache-Control, ETag, and Last-Modified. 1.Cache-Control is used to control caching policies. Example: Cache-Control:max-age=3600,public. 2. ETag verifies resource changes through unique identifiers, example: ETag: "686897696a7c876b7e". 3.Last-Modified indicates the resource's last modification time, example: Last-Modified:Wed,21Oct201507:28:00GMT.

In PHP, password_hash and password_verify functions should be used to implement secure password hashing, and MD5 or SHA1 should not be used. 1) password_hash generates a hash containing salt values to enhance security. 2) Password_verify verify password and ensure security by comparing hash values. 3) MD5 and SHA1 are vulnerable and lack salt values, and are not suitable for modern password security.

PHP is a server-side scripting language used for dynamic web development and server-side applications. 1.PHP is an interpreted language that does not require compilation and is suitable for rapid development. 2. PHP code is embedded in HTML, making it easy to develop web pages. 3. PHP processes server-side logic, generates HTML output, and supports user interaction and data processing. 4. PHP can interact with the database, process form submission, and execute server-side tasks.

PHP has shaped the network over the past few decades and will continue to play an important role in web development. 1) PHP originated in 1994 and has become the first choice for developers due to its ease of use and seamless integration with MySQL. 2) Its core functions include generating dynamic content and integrating with the database, allowing the website to be updated in real time and displayed in personalized manner. 3) The wide application and ecosystem of PHP have driven its long-term impact, but it also faces version updates and security challenges. 4) Performance improvements in recent years, such as the release of PHP7, enable it to compete with modern languages. 5) In the future, PHP needs to deal with new challenges such as containerization and microservices, but its flexibility and active community make it adaptable.

The core benefits of PHP include ease of learning, strong web development support, rich libraries and frameworks, high performance and scalability, cross-platform compatibility, and cost-effectiveness. 1) Easy to learn and use, suitable for beginners; 2) Good integration with web servers and supports multiple databases; 3) Have powerful frameworks such as Laravel; 4) High performance can be achieved through optimization; 5) Support multiple operating systems; 6) Open source to reduce development costs.


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Safe Exam Browser
Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

Notepad++7.3.1
Easy-to-use and free code editor

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool