什么是负载测试SignalR中心应用程序的最佳方法是什么? [英] What is the best way to load test a SignalR hubs application?

查看:366
本文介绍了什么是负载测试SignalR中心应用程序的最佳方法是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道的一些已被用于测试基于集线器SignalR应用不同的方法

I would like to know some of the different methods that have been used to test a SignalR hubs-based application.

推荐答案

在总之,如果使用集线器,使用.NET客户端就足够了。

In short, if using Hubs, using the .Net client will suffice.

在我的情况,我有一个新闻源集线器出来的菜肴根据用户的配置文件ID特定的客户端的数据。在我的测试情况下,我打开了一堆文件ID的(6000),此调用称为JoinNewsfeed()与特定客户端连接ID和配置文件ID沿枢纽方法。每100ms一个新的连接被建立。

In my case, I have a newsfeed hub that dishes out client-specific data based on the user's profile ID. In my test case, I load up a bunch of profile ID's (6000 in this case), invoke a hub method called JoinNewsfeed() along with the client-specific connection ID and profile ID. Every 100ms a new connection is established.

    [TestMethod]
    public void TestJoinNewsfeedHub()
    {
        int successfulConnections = 0;

        // get profile ID's
        memberService = new MemberServiceClient();
        List<int> profileIDs = memberService.GetProfileIDs(6000).ToList<int>();

        HubConnection hubConnection = new HubConnection(HUB_URL);
        IHubProxy newsfeedHub = hubConnection.CreateProxy("NewsfeedHub");


        foreach (int profileID in profileIDs)
        {
            hubConnection.Start().Wait();
            //hubConnection = EstablishHubConnection();
            newsfeedHub.Invoke<string>("JoinNewsfeed", hubConnection.ConnectionId, profileID).ContinueWith(task2 =>
            {
                if (task2.IsFaulted)
                {
                    System.Diagnostics.Debug.Write(String.Format("An error occurred during the method call {0}", task2.Exception.GetBaseException()));
                }
                else
                {
                    successfulConnections++;
                    System.Diagnostics.Debug.Write(String.Format("Successfully called MethodOnServer: {0}", successfulConnections));

                }
            });

            Thread.Sleep(100);

        }

        Assert.IsNotNull(newsfeedHub);
    }

这里列出

性能指标做服务器上的伎俩。为了确保客户端已实际上连接和服务器上填充客户对象的过程已成功完成,我有调用客户端功能的数量和从所述连接的客户端衍生的连接的客户端的列表的服务器端方法集合。

Performance metrics listed here do the trick on the server. To ensure that a client has in fact connected and the process of populating client object on the server has successfully completed, I have a server-side method that invokes a client-side function with the number and list of connected clients derived from the connected client collection.

这篇关于什么是负载测试SignalR中心应用程序的最佳方法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆