zoukankan      html  css  js  c++  java
  • rabbtimq非持久化测试

    send端代码

    import pika,time,threading
    class send():
        def __init__(self,que_nam='hello'):
            self.credentials = pika.PlainCredentials('mytest', 'mytest')
            self.connection = pika.BlockingConnection(pika.ConnectionParameters(host='192.168.157.132',credentials=self.credentials))
            self.channel = self.connection.channel()
            self.channel.queue_declare(queue=que_nam)
        def action(self,msgj='ndyd 996'):
            while True:
                self.channel.basic_publish(exchange='',
                                  routing_key='hello',
                                  body=msgj)
            print(" [x] Sent %s" %msgj)
            time.sleep(0.5)
        def lll(self):
            li=[]
            for i in range(1,1000):
                th=threading.Thread(target=self.action())
                th.start()
                li.append(th)
            for i in li:
                i.join()
            # connection.close()
    song=send()
    song.lll()

    消费端代码

    import pika
    
    class send():
        def __init__(self,msg='ndyd 996',que_nam='hello'):
            self.credentials = pika.PlainCredentials('mytest', 'mytest')
            self.connection = pika.BlockingConnection(pika.ConnectionParameters(host='192.168.157.132',credentials=self.credentials))
            self.channel = self.connection.channel()
            self.channel.queue_declare(queue=que_nam)
    
        def callback(self,ch, method, properties, body):
            print(" [x] Received %r" % body)
    
        def start(self):
            self.channel.basic_consume(self.callback,
                              queue='hello',
                              no_ack=True)
    
            print(' [*] Waiting for messages. To exit press CTRL+C')
            self.channel.start_consuming()
    song=send()
    song.start()

    rabbitmq配置

    [root@localhost ~]# free -h
                  total        used        free      shared  buff/cache   available
    Mem:           472M        107M        296M        1.5M         67M        326M
    Swap:          2.0G         88M        1.9G
    [root@localhost ~]# lscpu 
    Architecture:          x86_64
    CPU op-mode(s):        32-bit, 64-bit
    Byte Order:            Little Endian
    CPU(s):                1
    On-line CPU(s) list:   0
    Thread(s) per core:    1
    Core(s) per socket:    1
    Socket(s):             1
    NUMA node(s):          1
    Vendor ID:             GenuineIntel
    CPU family:            6
    Model:                 94
    Model name:            Intel(R) Core(TM) i5-6300HQ CPU @ 2.30GHz
    Stepping:              3
    CPU MHz:               2303.139
    BogoMIPS:              4608.00
    Hypervisor vendor:     VMware
    Virtualization type:   full
    L1d cache:             32K
    L1i cache:             32K
    L2 cache:              256K
    L3 cache:              6144K
    NUMA node0 CPU(s):     0
    Flags:                 fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ss syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon nopl xtopology tsc_reliable nonstop_tsc eagerfpu pni pclmulqdq ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand hypervisor lahf_lm abm 3dnowprefetch fsgsbase tsc_adjust bmi1 hle avx2 smep bmi2 invpcid rtm mpx rdseed adx smap clflushopt xsaveopt xsavec arat

    稳定发送速率

     停止接收端 rabbitmq 瞬间崩溃

  • 相关阅读:
    Node.js理解
    PayPal为什么从Java迁移到Node.js
    移动开发技巧总结
    Flex性能调优相关的一些总结
    Flex组件的生命周期
    Adobe Flash Builder 4.7 新功能详解
    【Django】Cookie
    【Django】路由系统
    【Django】视图系统
    【Django】ORM操作#2
  • 原文地址:https://www.cnblogs.com/leleyao/p/10612028.html
Copyright © 2011-2022 走看看