azure之MSSQL服务性能测试

        azure给我们提供非常多的服务而这些服务可以让企业轻而易举地在上构建一个健壮的服务体系.但在使用azure的相关产品服务时还是应该对相关的服务有一些简单的性能了解才能更好的让企业购买适合自己的服务产品.MSSQL是azure提供的一个服务产品之一,它提供了多个性能等级给用户选择,但在一些性能描述上很让你有所理解;下面通过简单的测试看一下azure上的MMSQL针对企业的几个等级P1,P2和P3的并发处理能力.

测试用例

        测试针对Northwind的数据库进行压力测试,具体测试用例如下:

  • 随机获取订单和相关明细
                int i =  System.Threading.Interlocked.Increment(ref mIndex)%mOrderids.Count;
                int orderid = mOrderids[i];
                (Model.Orders.orderID == orderid).ListFirst<Model.Orders>(cc);
                if (DB == Peanut.DB.DB2 || DB == Peanut.DB.DB3)
                {
                    using (Peanut.DBContext.ChangeTable<Model.OrderDetails>("`Order Details`"))
                    {
                       
                        (Model.OrderDetails.orderID == orderid).List<Model.OrderDetails>(cc);
                    }
                }
                else
                {
                    (Model.OrderDetails.orderID == orderid).List<Model.OrderDetails>(cc);
                }
  • 添加雇员
                string id = Guid.NewGuid().ToString("N");
                Model.Employees item = new Model.Employees();
                item.Address = "gz"+id;
                item.City = "gz";
                item.Country = "cn";
                item.Region = "gd";
                item.Title = "程序员";
                item.BirthDate = DateTime.Now.AddYears(-10);
                item.HireDate = item.BirthDate.AddDays(20) ;
                item.FirstName = "fan";
                item.LastName = "henry";
                item.Notes = id;
                item.Save(cc);
  • 获取客户订单的TOP 10
     int i = System.Threading.Interlocked.Increment(ref mIndex) % mCustomers.Count;
                string customerid = mCustomers[i];
                Peanut.SQL SQL;
                if (DB == Peanut.DB.DB2 || DB == Peanut.DB.DB3)
                {
                    SQL = "select * from northwind.Orders where customerid=@p1 limit 0,10";
                }
                else
                {
                    SQL = "select top 10 * from Orders where customerid=@p1";
                }
                SQL["p1", customerid].List<Model.Orders>(cc);
  • 添加订单和明细(事务)
     Orders order = new Orders();
                    order.EmployeeID = mEmployeesID[mEmployeeIndex % mEmployeesID.Count];
                    order.CustomerID = mCustomersID[mCustomerIndex % mCustomersID.Count];
                    order.ShipVia = mShippers[mShippersIndex % mShippers.Count];
                    order.Freight = 94.5m;
                    order.OrderDate = mOrderDateTime[mOrderDateTimeIndex % mOrderDateTime.Count];
                    order.RequiredDate = order.OrderDate.AddDays(30);
                    order.ShippedDate = order.OrderDate.AddDays(30);
                    order.ShipAddress = "gz ld";
                    order.ShipCity = "gz";
                    order.ShipCountry = "cn";
                    order.ShipName = "sdfsdf";
                    order.ShipPostalCode = "510500";
                    order.ShipRegion = "gd";
                    order.Save(cc);
                    int orderid = sql.GetValue<int>(cc);
                    int items = mDetails[mDetailsIndex % mDetails.Count];
                    int pindex = mProductIndex;
                    for (int i = 0; i < items; i++)
                    {
                        pindex++;
                        Products product = mProducts[pindex % mProducts.Count];
                        OrderDetails detail = new OrderDetails();
                        detail.OrderID = orderid;
                        detail.ProductID = product.ProductID;
                        detail.Quantity = 5;
                        detail.UnitPrice = product.UnitPrice;
                        detail.Discount = 0.8;
                        if (DB == Peanut.DB.DB2 || DB == Peanut.DB.DB3)
                        {
                            using (Peanut.DBContext.ChangeTable<Model.OrderDetails>("`Order Details`"))
                            {
                                detail.Save(cc);
                            }
                        }
                        else
                        {
                            detail.Save(cc);
                        }
                    }
                    cc.Commit();

测试结果

  • P1
  • P2
  • P3

总结

        从测试结果来看对于普通应用来说是足够的,不过针对一些相对来说并发有点高的互联网企业来说估计会有点压力。不过在规划的时候可以考虑主次业务分离把业务核心存储到MSSQL而读支撑由nosql的服务产品来支撑,毕竟azure还提供了其他存储服务选择。不过从价格上来看P3的费用还是比较高的,在国内大概是3W多一个月,这个价格其实可以在azure搭建linux+mariadb从性能上来说会得到一个更理想的效能。(接下来将会测试一下azure linux+mariadb的处理能力)

 

下载测试代码?

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。