All Projects → songxinjianqwe → Webserver

songxinjianqwe / Webserver

手写简化版Web服务器

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to Webserver

Voovan
Voovan是高性能异步通信、HTTP服务器和客户端通信、动态编译支持、数据库操作帮助类等工具的框架, 如果项目觉得不错, 请点一下 star, 谢谢
Stars: ✭ 221 (+148.31%)
Mutual labels:  nio, webserver
simplewebserver
SimpleWebServer 是一款使用Java基于NIO编写的超轻量级开源Web Application Server
Stars: ✭ 67 (-24.72%)
Mutual labels:  webserver, nio
Cookbook
🎉🎉🎉JAVA高级架构师技术栈==任何技能通过 “刻意练习” 都可以达到融会贯通的境界,就像烹饪一样,这里有一份JAVA开发技术手册,只需要增加自己练习的次数。🏃🏃🏃
Stars: ✭ 428 (+380.9%)
Mutual labels:  nio, tomcat
Bleeper
Library to manage your firmware configurations written in C++
Stars: ✭ 54 (-39.33%)
Mutual labels:  webserver
Restfeel
RESTFeel: 一个企业级的API管理&测试平台。RESTFeel帮助你设计、开发、测试您的API。
Stars: ✭ 59 (-33.71%)
Mutual labels:  tomcat
Curso Sistemas Web Com Spring Javascript Bootstrap
Stars: ✭ 74 (-16.85%)
Mutual labels:  tomcat
Docker springboot tomcat mysql demo
How to setup docker with SpringBoot on Tomcat and MySQL
Stars: ✭ 88 (-1.12%)
Mutual labels:  tomcat
Glusterfs Java Filesystem
GlusterFS for Java
Stars: ✭ 50 (-43.82%)
Mutual labels:  nio
Igropyr
a async http server base on libuv for Chez Scheme
Stars: ✭ 85 (-4.49%)
Mutual labels:  webserver
Cloud Note
基于分布式的云笔记(参考某道云笔记),数据存储在redis与hbase中
Stars: ✭ 71 (-20.22%)
Mutual labels:  tomcat
Uranus
Hierarchical Memo & Task Web-App
Stars: ✭ 71 (-20.22%)
Mutual labels:  tomcat
Joinfaces Maven Jar Example
JoinFaces Maven Jar Example
Stars: ✭ 62 (-30.34%)
Mutual labels:  tomcat
Suave
Suave is a simple web development F# library providing a lightweight web server and a set of combinators to manipulate route flow and task composition.
Stars: ✭ 1,196 (+1243.82%)
Mutual labels:  webserver
Qtwebserver
Qt based web application server
Stars: ✭ 56 (-37.08%)
Mutual labels:  webserver
Pric
Simple zero-config tool to create Private Certificate Authority & issue locally-trusted development server certificates with any domain names you'd like. SSL certificates for development purposes.
Stars: ✭ 87 (-2.25%)
Mutual labels:  webserver
Graceful Shutdown Spring Boot
Graceful Shutdown with Spring Boot (Demo)
Stars: ✭ 51 (-42.7%)
Mutual labels:  tomcat
Fxshop
基于SpringBoot+SpringCloud微服务的商城项目(demo版 不可用于生产)
Stars: ✭ 82 (-7.87%)
Mutual labels:  tomcat
Psi Probe
Advanced manager and monitor for Apache Tomcat, forked from Lambda Probe
Stars: ✭ 1,155 (+1197.75%)
Mutual labels:  tomcat
Setup Nginx Webserver
🚀Setup a perfect webserver on CentOS/Redhat 7.x guide with understanding.
Stars: ✭ 65 (-26.97%)
Mutual labels:  webserver
Jennet
A simple HTTP web framework written in Pony
Stars: ✭ 72 (-19.1%)
Mutual labels:  webserver

手写简化版Web服务器(包括HTTP服务器和Servlet容器)

具备的功能(均为简化版的实现):

  • HTTP Protocol
  • Servlet
  • ServletContext
  • Request
  • Response
  • Dispatcher
  • Static Resources & File Download
  • Error Notification
  • Get & Post & Put & Delete
  • web.xml parse
  • Forward
  • Redirect
  • Simple TemplateEngine
  • session
  • cookie
  • filter
  • listener

使用技术

基于Java BIO/NIO/AIO、多线程、Socket网络编程、XML解析、log4j/slf4j日志 基于Spring的PathMatcher实现SpringMVC风格的路径匹配

打包

  • 必须使用maven的assembly插件,它可以把依赖的jar包打进来并且解压
  • 需要指定resources/webapp等,把除了源码之外的资源文件包含进来
  • class.getResource方法不推荐使用,因为在jar包中的文件路径是有空格的,但是getResource方法得到的是URL,是没有空格的。如果一定要在jar包中使用getResource,那么必须将URL中的文件路径中的%20替换为空格getClass().getResource("/a.txt").getPath().replaceAll("%20", " ")
  • 或者直接使用getResourceAsStream方法,可以避免这个问题

BIO

一个Acceptor阻塞式获取socket连接,然后线程池阻塞式等待socket读事件,处理业务逻辑,最后写回 每个HTTP连接结束后由客户端关闭TCP连接

NIO Reactor

多个(1个或2个)Acceptor阻塞式获取socket连接,然后多个Poller(处理器个数个)非阻塞式轮询socket读事件,检测到读事件时将socket交给线程池处理业务逻辑 实现HTTP的keep-alive(复用socket连接)

image

未来希望添加的功能:

  • 手写WebSocket服务器,实现HTTP长连接
  • 实现AsyncServlet
  • 实现多应用隔离,自定义类加载器体系

另附CSDN相关博客

http://blog.csdn.net/songxinjianqwe/article/details/75670552

AIO

实现一个AIO版本

压力测试

BIO

使用JMeter进行压力测试:connection:close 以下测试总请求次数都为20000次

2个线程,每个线程循环访问10000次,吞吐量为556个请求/sec,平均响应时间为3ms 20个线程,每个线程循环访问1000次,吞吐量为650个请求/sec,平均响应时间为22ms 200个线程,每个线程循环访问100次,吞吐量为644个请求/sec,平均响应时间为209ms 1000个线程,每个线程循环访问20次,吞吐量为755个请求/sec,平均响应时间为774ms

NIO

使用JMeter进行压力测试:connection:keep-alive 以下测试总请求次数都为20000次

2个线程,每个线程循环访问10000次,吞吐量为559个请求/sec,平均响应时间为2ms 20个线程,每个线程循环访问1000次,吞吐量为651个请求/sec,平均响应时间为21ms 200个线程,每个线程循环访问100次,吞吐量为659个请求/sec,平均响应时间为201ms 1000个线程,每个线程循环访问20次,吞吐量为503个请求/sec,平均响应时间为1396ms

AIO

使用JMeter进行压力测试:connection:keep-alive 以下测试总请求次数都为20000次

2个线程,每个线程循环访问10000次,吞吐量为633个请求/sec,平均响应时间为2ms 20个线程,每个线程循环访问1000次,吞吐量为764个请求/sec,平均响应时间为16ms 200个线程,每个线程循环访问100次,吞吐量为738个请求/sec,平均响应时间为170ms 1000个线程,每个线程循环访问20次,吞吐量为704个请求/sec,平均响应时间为677ms,但有接近20%的错误率,错误信息是connection refused

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].