Skip to content
Henry edited this page Sep 26, 2019 · 22 revisions

FastHttpApi是基于Beetlex扩展的轻量级高性能的HTTP服务组件。由于组件完全基于通讯层扩展并提供了非常轻量级的架构,因此性能上有非常出色的表现;组件不仅提供出色的性,在功能上也提供完善的支持。

  • 支持.NETCore 2.1或.NETStandard2.0更高版本
  • 支持http和ws,提供安全可靠的ssl,轻松配置即可实现https和wss服务。
  • 完善的会话管理,并支持cookie和header功能处理
  • 支持类控制器的方式来定义服务,让服务制定更简便
  • 提供完善的过虑器和自定义内容输出,可应对不同的服务请求响应处理
  • 支持静态资源和热更新
  • 支持Linux,Windows等多平台部署
  • Json
  • Single query
  • Multiple queries
  • Fortunes

性能对比测试

  • Asp.net core webapi
    public class HomeController : Controller
    {
        public class JsonMessage
        {
            public string message { get; set; }
        }
        public string plaintext()
        {
            return "Hello, World!";
        }
        public object json()
        {
            return new JsonMessage { message = "Hello, World!" };
        }

        public List<Employee> Employees()
        {
            return DataHelper.Defalut.Employees;
        }
        public Employee Employee(int id)
        {
            Employee result = DataHelper.Defalut.Employees.Find(e => e.EmployeeID == id);
            if (result == null)
                result = new Employee();
            return result;
        }
        public object Orders(int id, string customerid, int index, int size)
        {
            Func<Order, bool> exp = o => (id == 0 || o.EmployeeID == id)
             && (string.IsNullOrEmpty(customerid) || o.CustomerID == customerid);
            int count = DataHelper.Defalut.Orders.Count(exp);
            if (size == 0)
                size = 10;
            int pages = count / size;
            if (count % size > 0)
                pages++;
            var items = DataHelper.Defalut.Orders.Where(exp).Skip(index * size).Take(size);
            return items;
        }
    }
  • FastHttpApi
    [Controller(BaseUrl = "Home")]
    public class Controller
    {
        public class JsonMessage
        {
            public string message { get; set; }
        }

        public object plaintext()
        {
            return new TextResult("Hello, World!");
        }

        public object json()
        {
            return new JsonResult(new JsonMessage { message = "Hello, World!" });
        }

        public List<Employee> Employees()
        {
            return DataHelper.Defalut.Employees;
        }

        [Get(Route = "{id}")]
        public object Employee(int id)
        {
            Employee result = DataHelper.Defalut.Employees.Find(e => e.EmployeeID == id);
            if (result == null)
                result = new Employee();
            return new JsonResult(result);
        }
        [Get(Route = "{id}")]
        public object Orders(int id, string customerid, int index, int size)
        {
            Func<Order, bool> exp = o => (id == 0 || o.EmployeeID == id)
             && (string.IsNullOrEmpty(customerid) || o.CustomerID == customerid);
            int count = DataHelper.Defalut.Orders.Count(exp);
            if (size == 0)
                size = 10;
            int pages = count / size;
            if (count % size > 0)
                pages++;
            var items = DataHelper.Defalut.Orders.Where(exp).Skip(index * size).Take(size);
            return new JsonResult(items);

        }
    }
  • 完整测试代码

https://github.com/IKende/FastHttpApi/tree/master/PerformanceTest/Beetlex_VS_AspCore_webapi

Clone this wiki locally