- r - 以节省内存的方式增长 data.frame
- ruby-on-rails - ruby/ruby on rails 内存泄漏检测
- android - 无法解析导入android.support.v7.app
- UNIX 域套接字与共享内存(映射文件)
我正在尝试编写一个小型 http 服务器,以便以后使用 Google 的 Go 语言进行扩展。我在 Windows 上使用 Go(MinGw 编译版本)。
这在这门语言中很容易,因为它已经有了必要的包:
package main
import (
"http"
"io"
"os"
"fmt"
"strconv"
)
func FileTest(w http.ResponseWriter, req *http.Request) {
w.Header().Add("Content-Type", "image/jpeg")
w.Header().Add("Content-Disposition", "inline; filename=image.jpg")
inName := "d:\\googlego\\somepic.jpg";
inFile, inErr := os.OpenFile(inName, os.O_RDONLY, 0666);
if inErr == nil {
inBufLen := 16;
inBuf := make([]byte, inBufLen);
_, inErr := inFile.Read(inBuf);
for inErr == nil {
w.Write(inBuf)
_, inErr = inFile.Read(inBuf);
}
}
inErr = inFile.Close();
}
func MainPage(w http.ResponseWriter, req *http.Request) {
io.WriteString(w, "Hi, download here: <a href=\"/FileTest\">HERE</a>")
}
func main() {
fmt.Print("Port: ")
var hi int
fmt.Scanf("%d", &hi)
http.HandleFunc("/FileTest", FileTest)
http.HandleFunc("/", MainPage)
err := http.ListenAndServe("0.0.0.0:" + strconv.Itoa(hi), nil)
if err != nil {
fmt.Print(err)
fmt.Print((hi))
}
}
这将启动一个服务器,该服务器提供主页和图像下载。两者都工作得很好,我从最多 6 个并发线程的 ab(Apache 基准测试)中获得了非常好的结果:
> ab -n 10000 -c 6 http://localhost:8080/
Concurrency Level: 6
Time taken for tests: 1.678096 seconds
Complete requests: 10000
Percentage of the requests served within a certain time (ms)
50% 1
66% 1
75% 1
80% 1
90% 2
95% 2
98% 2
99% 2
100% 3 (longest request)
当并发级别设置得较高时,会出现这种情况:
>ab -n 1000 -c 7 http://localhost:8080/
Concurrency Level: 7
Time taken for tests: 10.239586 seconds
Complete requests: 1000
Percentage of the requests served within a certain time (ms)
50% 1
66% 2
75% 2
80% 3
90% 499
95% 505
98% 507
99% 507
100% 510 (longest request)
请注意,这次我只发出了 1,000 个请求,但仍然花费了将近 6 倍的时间。
两个基准测试甚至还没有请求文件。
我对 Go 还不是很了解,但似乎 Go 运行时没有创建足够的操作系统线程来放置 goroutines 或类似的东西?
编辑:我从 07.10.2011 下载了新的 r60.2。
现在它变得更更糟:
>ab -c 7 -n 1000 http://localhost:8080/
Concurrency Level: 7
Time taken for tests: 12.622722 seconds
Complete requests: 1000
Percentage of the requests served within a certain time (ms)
50% 1
66% 1
75% 2
80% 2
90% 496
95% 503
98% 506
99% 506
100% 507 (longest request)
最佳答案
截至今天(2011 年 9 月),Go 的 Windows 端口仍在开发中。它在包括稳定性和性能在内的一些重要指标上落后于其他受支持的平台(Linux 等)(尽管它每天都在改进)。我建议您在 64 位 Linux 平台上尝试您的测试,看看它有何不同,然后也许您可以开始解构 Windows 下出现的问题。
关于windows - 谷歌去 : Why does the http server package not serve more than 5 simultaneous requests?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7573850/
Serv-U 密匙冲突,Serv-U无法启动处于离线状态解决方法 大家也许会遇到,在服务器上安装SERV-U时会出现密匙冲突提示。就算汉化时钩选破解也没有用。去网上找,很多密匙要么快过期了,要么没
How can I properly simulate a cloud function locally so that it has all data as when being invoked o
我一直在使用 Angular2 进行 Web 开发,并且一直在使用 Angular2 和 Firebase 来运行本地服务器。在使用Ionic创建服务器时,我一直没能找到类似于键入quit的命令,因此
我正在尝试使用 --serve-path 在该路径下为我的整个应用程序提供服务。例如,我希望我的路径是 localhost:4200/foobar 我使用 ng serve --serve-path=
目前正在学习Jekyll,一个建站框架,不知道bundle exec jekyll serve和jekyll serve有什么区别。两者的行为似乎相同。 最佳答案 两个字: bundle exec j
很快,我在 ng serve 上有一个 4.6MB 的应用。 当我这样做时: ng serve --prod 我得到 1MB 的文件大小。 但是,--prod 以某种方式使我的整个应用程序中断。 我向
您好,我正在尝试构建我的 React 应用程序,所以我做了 yarn build它创建了必要的文件夹,现在我正在尝试做 serve -s build它告诉我下面的错误 ** 我尝试通过 npm uni
我用过 ionic serve并得到以下回复,我没有三思而后选择 localhost .但是现在我想使用选项 1。Ionic 记住了我的选择,例如 ionic serve从不允许我再选择并使用 loc
将图像(例如)保存在内存中而不是从静态 Assets 中提供它们是否值得? 频繁请求的静态资源会保留在内存中吗? 谁能告诉我性能影响? 最佳答案 除非您以每秒数千的速度为用户提供服务,否则我怀疑它会产
我的理解是,我应该能够从 Google 的 AI Hub 中获取 TensorFlow 模型,将其部署到 TensorFlow Serving 并使用它通过使用 curl 的 REST 请求发布图像来
我正在使用 Angular 7,我想知道是否 ng serve --prod 与相同 ng serve -c production 在文档中找不到,所以任何帮助将不胜感激 最佳答案 这里有一些文档:h
使用 struts.serve.static=true 和 struts,serve.static.browserCache=false 标记的浏览器缓存不起作用我有一个要求,即使用户注销并单击后退按
它曾经可以工作,但是当我重新启动我的电脑时,它就不再工作了。 nodejs目录设置在Path环境变量中。我尝试重新安装 nodejs。我还尝试卸载 @vue 文件夹,以管理员身份运行我的 git ba
互联网的应用已经波及了我们的方方面面,那么加快对于网络的学习也是必要的。所以今天我们来介绍一下Serv-U的FTP服务器的架构。本文将结合Serv-U这一功能强大,界面友好,易学易用的FTP服务器端
注意:上面是FTP服务器端建立FTP用户的教程,建立FTP用户我们需要通过FTP客户端连接服务器的FTP,从而使用FTP上传文件到服务器或下载
前言: 大家应该都还没有忘记三年前在Serv-U5.004版的之前所有版本的"Serv-U FTPMDTM命令缓冲区溢出"与"Serv-U FTP服务器LIST命令超长
比起IIS来,Serv-U的管理功能强大得多,而且设置也很方便。需要特别注意的是每进行任何一次设置或改动,都要点击界面左上角工具条的“保存”按钮才能生效。 1.账户管理 Serv-U对账户的管理
Serv-U FTP Server是一种被广泛运用的FTP服务器端软件,可以设定多个FTP服务器、限定登录用户的权限、登录主目录及空间大小等,功能非常完备.具有非常完备的安全特性,支持SSl FT
我是 Angular 的新手,我克隆了一个 repo (angular-slider)。我的问题是,当我输入控制台 grunt serve 时,它显示警告:找不到任务“服务”。使用 --force
我正在使用运行 Node v8.11.3 的 Gatsby v1.1.52。 当我跑 gatsby serve我收到一条消息,提示我有一个 UPDATE AVAILABLE: The latest v
我是一名优秀的程序员,十分优秀!