Merge remote-tracking branch 'LCTT/master'

This commit is contained in:
Xingyu Wang 2019-12-28 17:37:09 +08:00
commit 38cd154fef
2 changed files with 210 additions and 9 deletions

View File

@ -1,8 +1,8 @@
[#]: collector: (lujun9972)
[#]: translator: (wxy)
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: reviewer: (wxy)
[#]: publisher: (wxy)
[#]: url: (https://linux.cn/article-11724-1.html)
[#]: subject: (Unix is turning 50. What does that mean?)
[#]: via: (https://www.networkworld.com/article/3511428/unix-is-turning-50-what-does-that-mean.html)
[#]: author: (Sandra Henry-Stocker https://www.networkworld.com/author/Sandra-Henry_Stocker/)
@ -12,17 +12,17 @@ Unix 即将迎来 50 岁
Unix 时间(又称为“<ruby>纪元时间<rt>epoch time</rt></ruby>”)是自 1970 年 1 月 1 日以来经过的秒数。当 Unix 即将 50 岁时,让我们看一下让内核开发人员担心的地方。
[cbaquiran][1]
![](https://img.linux.net.cn/data/attachment/album/201912/28/120311hzghpxux1hp5t4xo.jpg)
对于 Unix 而言2020 年是重要的一年。在这一年年初Unix 进入 50 岁。
尽管 Unix 的某些早期开发早于其“纪元”的正式开始,但 1970 年 1 月 1 日仍然是 POSIX 时间的零点,也是公认的 Unix 的万物之始。自那一刻算起2020 年 1 月 1 日将是其 50 周年。
尽管 Unix 的某些早期开发早于其“纪元”的正式开始,但 1970 年 1 月 1 日仍然是 POSIX 时间的零点,也是公认的 Unix 的万物之始。自那一刻算起2020 年 1 月 1 日将是其 50 周年。LCTT 译注:实际上,在 1971/11/3 出版的第一版《Unix 程序员手册》中,将 1971/1/1 作为 Unix 纪元的开始,并且一秒钟记录 60 个数,但是后来发现这样 32 位整型数字只能记录两年多,后来这个纪元被一再重新定义,改为从 1970/1/1 开始,每秒 1 个数。)
### Unix 时间与人类时间
就人类时间而言50 年是很重要的。就 Unix 时间而言50 年没有什么特别的。48.7 年同样重要。
Unix包括 Linux系统将日期/时间值存储为自 1970-01-01 00:00:00 UTC 以来经过的秒数32 位二进制)。要确定自该时间以来经过了几秒钟,看看 Unix 时间值是什么样子,你可以发出如下命令:
Unix包括 Linux系统将日期/时间值存储为自 1970-01-01 00:00:00 UTC 以来经过的秒数32 位整型)。要确定自该时间以来经过了多少秒钟,看看 Unix 时间值是什么样子,你可以发出如下命令:
```
$ date +%s
@ -47,7 +47,7 @@ $ echo '2^31' | bc
2147483648
```
并且,由于 Unix 计数以 0 开头,这意味着我们有 2,147,483,648 个值,但最大的可能值为 2,147,483,647 个。Unix 日期/时间值不能超过该数字——就像汽车上的里程表可能不能超过 999,999 英里一样。加 1 该值就变为了 -2147483648。LCTT 译注:此处原文描述有误,已修改。在达到最大值之后,即 2018/1/19 03:14:07下 1 秒导致符号位变为 1其余 31 位为 0即 -2147483648时间变为 1901/12/13 20:45:52这就是 Y2K38 问题。)
并且,由于 Unix 计数以 0 开头,这意味着我们有 2,147,483,648 个值,但最大的可能值为 2,147,483,647 个。Unix 日期/时间值不能超过该数字——就像汽车上的里程表可能不能超过 999,999 英里一样。加 1 该值就变为了 -2147483648。LCTT 译注:此处原文描述有误,已修改。在达到最大值之后,即 2038/1/19 03:14:07下 1 秒导致符号位变为 1其余 31 位为 0即 -2147483648时间变为 1901/12/13 20:45:52这就是 Y2K38 问题。)
### 一年有多少秒?
@ -65,6 +65,8 @@ $ expr 24 \* 60 \* 60 \* 366
31622400
```
LCTT 译注Unix 时间将一天精确定义为 24 * 60 * 60 = 86400 秒,忽略闰秒。)
### Unix 将如何庆祝其 50 岁生日?
2020 年 1 月 1 日中午 12:00 是纪元时间的 1577836800。这个计算有些棘手但主要是因为我们必须适应闰年。自该纪元开始以来我们经历了 12 个闰年,从 1972 年开始,到上一个闰年是 2016 年。而且,当我们达到 2020 年时,我们将有 38 个常规年份。
@ -83,7 +85,7 @@ $ expr 31536000 \* 38 + 31622400 \* 12
1577836800
```
这种跟踪日期和时间的方式使 Unix 系统完全不受 Y2K 恐慌的影响1999 年末人们开始担心进入 2000 年会对计算机系统造成严重破坏但是实际遇到的问题比人们担心的少得多。实际上,只有以两位数格式存储年份的应用程序才会将年份变为 00以表示时间倒退。尽管如此许多应用程序开发人员还是做了很多额外的繁琐工作以确保 2000 年到来时,他们的系统不会出现严重问题。
这种跟踪日期和时间的方式使 Unix 系统完全不受 Y2K 恐慌的影响1999 年末人们开始担心进入 2000 年会对计算机系统造成严重破坏但是实际遇到的问题比人们担心的少得多。实际上,只有以两位数格式存储年份的应用程序才会将年份变为 00以表示时间倒退。尽管如此许多应用程序开发人员还是做了很多额外的繁琐工作以确保 2000 年到来时,他们的系统不会出现严重问题。
### Unix 时间何时会遇到问题?
@ -91,6 +93,8 @@ $ expr 31536000 \* 38 + 31622400 \* 12
2038 年的问题有时称为 Y2K38 问题。我们必须在 2038 年 1 月 19 日星期二之前解决这个问题。如果问题到时候仍未解决,则该日期之后的系统可能会认为是 1901 年。解决该问题的一种方法是切换为日期/时间信息的 64 位表示形式。有些人认为即使那样也会有比听起来更复杂的问题。无论如何恐慌还为时过早。并且与此同时也许在新年前夜演唱了《Auld Lang Syne》之后你可以向 Unix 唱《生日快乐》歌了。Unix 50 岁了,这仍然是大事。
LCTT 译注:建议阅读一下 Unix 时间的[维基百科][6]页面,有更多有趣和不为人知的信息。)
--------------------------------------------------------------------------------
via: https://www.networkworld.com/article/3511428/unix-is-turning-50-what-does-that-mean.html
@ -98,7 +102,7 @@ via: https://www.networkworld.com/article/3511428/unix-is-turning-50-what-does-t
作者:[Sandra Henry-Stocker][a]
选题:[lujun9972][b]
译者:[wxy](https://github.com/wxy)
校对:[校对者ID](https://github.com/校对者ID)
校对:[wxy](https://github.com/wxy)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
@ -109,3 +113,4 @@ via: https://www.networkworld.com/article/3511428/unix-is-turning-50-what-does-t
[3]: https://www.networkworld.com/article/3440100/take-the-intelligent-route-with-consumption-based-storage.html?utm_source=IDG&utm_medium=promotions&utm_campaign=HPE20773&utm_content=sidebar ( Take the Intelligent Route with Consumption-Based Storage)
[4]: https://www.facebook.com/NetworkWorld/
[5]: https://www.linkedin.com/company/network-world
[6]: https://en.wikipedia.org/wiki/Unix_time

View File

@ -0,0 +1,196 @@
[#]: collector: (lujun9972)
[#]: translator: ( )
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: subject: ("server" is hard to define)
[#]: via: (https://jvns.ca/blog/2019/12/26/whats-a-server/)
[#]: author: (Julia Evans https://jvns.ca/)
"server" is hard to define
======
Somebody asked me recently what a server was, and I had a harder time explaining it than I expected! I thought I was going to be able to give some kind of simple pithy answer but it kind of got away from me. So heres an short exploration of what the word “server” can mean:
### a server responds to requests
A server definitely responds to requests. A few examples:
webserver:
```
Me: "please give me google.com"
Server: "here is the HTML for that webpage"
```
bittorrent server:
```
Me: "I would like this chunk of the good wife season 2"
Server: "here are some of the bytes from that .avi file!"
```
mail server:
```
Me: "can you send this email to [email protected]"
Server: "I sent it!"
```
But what is a server actually specifically exactly?
### a server is a program
My first instinct is to say “a server is a program” because for example a “the wordpress server” is a PHP program, so lets start with that.
A server is usually a program that listens on a **port** (like 80). For example, if were talking about a Rails webserver, then the program is a Ruby program thats listening on a port for HTTP requests.
For example, we can start a Python server to serve files out of the current directory.
```
$ python3 -m http.server &
Serving HTTP on 0.0.0.0 port 8000 (http://0.0.0.0:8000/) ..
```
and send requests to it with `curl`:
```
$ curl localhost:8000/config.yaml
baseurl: https://jvns.ca
disablePathToLower: true
languageCode: en-us
title: Julia Evans
author: Julia Evans
...
```
### a server might be a virtual machine
But often when I talk about “a server” at work, Ill use it in a sentence like “Im going to SSH to that server to see whats going on with it”, or “wow, that server is swapping a lot, thats bad!“.
So in those cases clearly I dont mean a program when I say “that server” (you cant ssh to a program, though the ssh server that runs on the VM is itself a program!), I mean the AWS instance that the server program is running on. That AWS instance is a virtual machine, which looks like a computer in a lot of ways (its running an operating system!) but it isnt a physical computer.
### a server might be a container
Similarly to how your server might be a virtual machine, it could also be a container running in a virtual machine. So “the server is running out of memory” could mean “the container is running out of memory and crashing” which really means “we set a cgroup memory limit on this container and the programs in the container with that cgroup exceeded the limit so the Linux kernel OOM killed them”.
But containers make everything a lot more complicated so I think we should stop there for now.
### a server is a computer
But also when you **buy** a server from Dell or some other computer company, youre not buying a virtual machine, youre buying an actual physical machine.
Usually these computers are in building datacenters. For example in this video you can see thousands of servers in a Google datacenter.
The computers in this datacenter dont look like the computers in my house! Theyre short and wide because theyre designed to fit into these giant racks of servers. For example if you search Newegg for [1U server][1] youll find servers that are 1 “[rack unit][2]” high, and a rack unit is 1.75 inches. There are also 2U servers which are twice as high.
Heres a picture of a 1U server I found on Newegg:
![][3]
Ive only seen a server rack once at the [Internet Archive][4] which is in what used to be a church in San Francisco, and it was really cool to realize wow, when I use the Wayback Machine its using the actual computers in this room!
### “the server” might be 1000 computers
Next, lets say were talking about how Gmail works. You might ask “hey, when I search my email to find my boarding pass, does that happen in the frontend or on the server?”.
The answer is “it happens on the server”, but whats “the server” here? Theres not just one computer or program or virtual machine that searches your Gmail, there are probably lots of computers and programs at Google that are reponsible for that and theyre probably distributed across many datacenters all over the world.
And even if were just talking about doing 1 search, there could easily be 20 different computers in 3 different countries involved in just running that 1 search.
So the words “the server” in “oh yeah, that happens on the server” mean something kind of complicated here what youre actually saying is something “well the browser makes a request, and that request does _something_, but Im not really going to worry about what because the important thing is just that the browser made a request and got some kind of response back.”
### what happens when I search my email for a boarding pass?
When I search for “boarding” in my email, the Javascript running on the frontend puts together this request. Its mostly indecipherable but it definitely contains the word “boarding”:
```
{
"1": {
"1": 79,
"2": 101,
"4": "boarding",
"5": {
"5": 0,
"12": "1577376926313",
"13": -18000000
},
"6": "itemlist-ViewType(79)-5",
"7": 1,
"8": 2000,
"10": 0,
"14": 1,
"16": {
"1": 1,
"2": 0,
"3": 0,
"7": 1
},
"19": 1
},
"3": {
"1": "0",
"2": 5,
"5": 1,
"6": 1,
"7": 1
}
}
```
We get a response back which is large and complicated and definitely contains search results from my email about boarding passes. Heres an excerpt:
```
"your electronic boarding pass. You could also be asked to display this \nmessage to airport security. * PLEASE NOTE: A printable",
"the attached boarding pass to present at the airport. Manage your booking \nBooking Details Passenger: JULIA EVANS Booking",
"Electronic boarding pass is not offered for your flight. Click the link \nbelow to access the PRINTABLE VERSION of your boarding",
"Save time at the airport Save time at the airport Web version",
"GET YOUR BOARDING PASS IN ADVANCE > You can now check in for your flight \nand you will receive a boarding pass > allowing",
"Save time at the airport Save time at the airport Web version",
"Booking Confirmation Booking Reference: xxxxxx Date of issue: xxxxxxxxxxxx \nSelect Seats eUpgrade",
"your electronic boarding pass. You could also be asked to display this \nmessage to airport security. * PLEASE NOTE: A printable",
"your electronic boarding pass. You could also be asked to display this \nmessage to airport security. * PLEASE NOTE: A printable",
"Save time at the airport Save time at the airport Web version",
"house was boarded up during the last round of bombings. I have no spatial \nimagination and cannot picture the house in three",
"Booking Confirmation Booking Reference: xxxxxx Date of issue: xxxxxxxxxxxx \nSelect Seats eUpgrade"
"required when boarding a flight to Canada. For more details, please visit \nCanada.ca/eTA . - Terms and Conditions of Sale",
"Your KLM boarding pass(s) on XXXXXX To: [image: KLM SkyTeam] Boarding \ninformation Thank you for checking in! Attached you",
"Boarding information Thank you for checking in! Attached you will find your \nboarding pass and/or other documents. Below",
"jetBlue® Your upcoming trip to SEATTLE, WA on xxxxxxxxxxx Flight status \nBaggage info Airport info TAG",
"your electronic boarding pass. You could also be asked to display this \nmessage to airport security. * PLEASE NOTE: A printable"
```
That request got sent to 172.217.13.197:443, which corresponds to some edge server near me. There were probably many other computers involved in searching my email than just the first one who got my request, but the nice thing about this is that we dont need to care exactly what happened behind the scenes! The browser sent a request, and it got search results back, and it doesnt need to know what servers.
We can just say “it happens on the server” and not worry too much about the ambiguity of what exactly that means (until something weird goes wrong :)).
### the meaning of “server” depends on the context
So weve arrived somewhere a little bit interesting at first when I thought about the question “whats a server?” I really thought there was going to be a single simple answer! But it turns out that if you look at sentences where we use the word “server” it can actually refer to a lot of different things in a way that can be confusing:
* “Let me just ssh into the server and see whats going on” =&gt; a virtual machine (or possibly a computer)
* “I sent a SIGTERM to the server and that fixed the problem” =&gt; a program
* “Lets look at the server code” =&gt; a program
* “Lets buy 20 of those 2U servers” =&gt; a computer
* “We need to add more server capacity” =&gt; a program and a virtual machine probably
* “That happens on the server” =&gt; possibly some complex distributed system
--------------------------------------------------------------------------------
via: https://jvns.ca/blog/2019/12/26/whats-a-server/
作者:[Julia Evans][a]
选题:[lujun9972][b]
译者:[译者ID](https://github.com/译者ID)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]: https://jvns.ca/
[b]: https://github.com/lujun9972
[1]: https://www.newegg.com/p/pl?d=1u+server
[2]: https://en.wikipedia.org/wiki/Rack_unit
[3]: https://c1.neweggimages.com/NeweggImage/ProductImage/11-152-136-02.jpg
[4]: https://archive.org/