面试Nginx的几个常见问题(
生活随笔
收集整理的這篇文章主要介紹了
面试Nginx的几个常见问题(
小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
1、Nginx 服務(wù)器上的 Master 和 Worker 進(jìn)程分別是什么
Master 進(jìn)程:讀取及評(píng)估配置和維持 Worker 進(jìn)程:處理請(qǐng)求?
2、怎么添加模塊?
Firstly, you have to select the Nginx module during the compile. Runtime selection of module is not being supported by the Nginx server.在編譯過程添加模塊
?
3、什么是 C10K 問題?
C10K 問題是指無法同時(shí)處理大量客戶端(10,000)的網(wǎng)絡(luò)套接字。?
4、在 Nginx 中,如何使用未定義的服務(wù)器名稱來阻止處理請(qǐng)求??
只需將請(qǐng)求刪除的服務(wù)器就可以定義為: Server {listen 80;server_name “ “ ;return 444; }?
5、Nginx和Apache的區(qū)別?
Firstly, Nginx is an event-based web server and Apache is a process-based server.1、Nginx是事件驅(qū)動(dòng),Apache是過程驅(qū)動(dòng)
Nginx is best known for its speed and Apache is best known for its power. Nginx is the best when it comes to memory consumption and connection whereas Apache is not best in this category. In Nginx, a single thread is handling all of the requests whereas in Apache single thread handles a single request. Nginx is best when you want the load balancing. But Apache will refuse the new connection when traffic reaches the limit of the process. Apache provides lots of functionality as compared to Nginx.
更為通用的方案是,前端 nginx 抗并發(fā),后端 apache 集群,配合起來會(huì)更好。
?
6、Nginx是什么語言寫的?
C語言?
7、Nginx的負(fù)載均衡策略有哪幾種?
輪詢 | 按照時(shí)間順序,逐一分配到不同的后端服務(wù)器 |
加權(quán)輪詢 | weight值越大,分配到的訪問幾率越高 |
ip_hash | 每個(gè)請(qǐng)求按訪問IP的hash結(jié)果分配,這樣來自同一個(gè)IP的請(qǐng)求固定訪問一個(gè)后端服務(wù)器,可以解決分布式session問題,但不是最優(yōu)的解決辦法,另一個(gè)即集中式session存儲(chǔ)校驗(yàn),將session放到redis集群當(dāng)中。 |
url_hash(第三方) | 按照訪問的URL的hash結(jié)果來分配請(qǐng)求,使一個(gè)URL始終定向到同一個(gè)后端服務(wù)器 |
less_conn | 最少連接數(shù),哪個(gè)機(jī)器連接數(shù)少,就分發(fā) |
fair(第三方) | 按后端服務(wù)器的響應(yīng)時(shí)間來分配請(qǐng)求,響應(yīng)時(shí)間短的優(yōu)先分配。 |
8、如何設(shè)置在81端口上運(yùn)行nginx? 修改nginx.conf里的端口號(hào)
?
參考:
https://www.onlineinterviewquestions.com/nginx-interview-questions/
https://www.jianshu.com/p/19d0516ea29e
https://segmentfault.com/a/1190000010677483
轉(zhuǎn)載于:https://www.cnblogs.com/roostinghawk/p/11073511.html
總結(jié)
以上是生活随笔為你收集整理的面试Nginx的几个常见问题(的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

- 上一篇: Linux后台运行和关闭程序、查看后台任
- 下一篇: C# 不能从数据库更新实体