线程池模式一般分为两种:L/F领导者与跟随者模式、HS/HA半同步/半异步模式。
HS/HA 半同步/ 半异步模式 :分为三层,同步层、队列层、异步层,又称为生产者消费者模式,主线程处理I/O事件并解析然后再往队列丢数据,然后消费者读出数据进行应用逻辑处理;
优点:简化编程将低层的异步I/O和高层同步应用服务分离,且没有降低低层服务性能。集中层间通信。
缺点:需要线程间传输数据,因此而带来的动态内存分配,数据拷贝,语境切换带来开销。高层服务不可能从底层异步服务效率中获益。
L/F 领导者跟随者模式 :在LF线程池中,线程可处在3种线程状态之一: leader、follower或processor。处于leader状态的线程负责监听tb网络端口,当有消息到达时,该线程负责消息分离,并从处于 follower状态中的线程中按照某种机制如FIFO或基于优先级等选出一个来当新的leader,然后将自己设置为processor状态去分配和处 理该事件。处理完毕后线程将自身的状态设置为follower状态去等待重新成为leader。在整个线程池中同一时刻只有一个线程可以处于leader 状态,这保证了同一事件不会被多个线程重复处理。
缺点:实现复杂性和缺乏灵活性;
优点:增强了CPU高速缓存相似性,消除了动态内存分配和线程间的数据交换。
两种模式性能分析:
L/F模式处理一个消息的时间为多路分离、分配、处理的时间,加上线程管理时间,LF中多个线程共享一个事件源,所以,需要协调它们间的行为,即 有同步开销,L/F同步开销仅为申请/释放锁的开销,在LF处理请求过程中并不需要线程上下文切换,但是在线程由follower成为leader时需要 进行线程上下文切换,所以当两个请求同时到达时,这种上下文切换会影响第二个请求的处理时间,也会带来一定的上下文开销。
T(L/F)=T(多路分离)+T(分配)+T(处理)+T(同步)+T(上下文)
HS/HA模式监听线程和工作线程间通过一个消息队列来交换数据。这会带来数据传递开销,。同时,监听线程和工作线程都需要去访问消息队列,造成 了资源的竞争,需要额外的同步机制来协调他们的行为,包括监听线程获取和释放资源锁,对应的工作线程获取和释放资源锁,以及监听线程在将一个请求放入队列 后通知工作线程带来的开销,我们称此为同步开销,HS/HA模式的同步开销大于L/F的同步开销,。一个请求由监听线程负责放入消息队列,但是却由工作线 程来处理,所以,每个请求都会造成一次线程上下文切
换,由此带来的开销我们称为上下文开销。
T (H/H)=T(多路分离)+T(分配)+T(处理)+T(同步)+T(数据传递)+T(上下文)
从上面分析可以看出没有并发情况下L/F模式线程池模式性能优于HS/HA模式。
并发性能分析:
T(多路分离)、T(分配):LF和HH中把每一个消息的到来当作一个事件来处理。tbw事件分配所做的工作是在一个事件处理器注册表中为一个事件查找 事件处理器。这一步骤花费的时间随着当前注册的事件处理器的个数变化。当线程池接受用户连接请求后会为每一个连接注册一个事件处理器,所有通过该连接发来 的请求都将由同一个事件处理器来处理。而事件处理器表采用一个平衡二叉树来实现。因此,事件分配的时间可以认为是随着并发用户数的增大而增大;
T(处理)处理消息和管理线程所需的时间都不受并发用户数的影响。
T(线程管理),多线程带来的线程管理开销只会随着线程池中线程数而变化,相对固定。
LF和HH的吞吐量会随着并发用户数的增加而增加。当并发用户数达到一定数量时,CPU成为系统瓶颈,此后增大并发用户数不仅不能增加并发处理的请求个数,反而会加大多路分离和分配的时间,从而使得系统吞吐量下降。
最佳性能时线程线:
随着线程数的增多吞吐量不断增大,当达到最大值后有一个短暂的保持阶段,此后继续增大线程数反而会使得吞吐量减小。而且当请求类型为计算密集型时线程数对
HH 的吞吐量的影响并不是很明显。原因是HH线程池在增加线程数时线程管理开销也有较大幅度的增加。因此,通过增大线程数来改善系统性能对HH来说并不是一种有效的方法。

69条回应:“L/F领导者与跟随者模式、HS/HA半同步/半异步模式连接池比较”

  1. 3d hoodies floral facts print

    adidas originals adidas originals adicolor tnt tape wind track jacket black br2290 blackyhsukruny custom crystal palace premier league adjustable baseball hatcap redsupreme classic pullover hoodieadidas jumpsuit and jacket yellow medium

  2. carteira gucci canvas bagme

    mochi as nike skateboarding mochi a nike skateboarding nike piedmont sport turq b ackmochi a mascu ina preta c a 莽a bo so boa e barata oferta r 40agasa ho feminino rainha muccashopcompre camisas de futebo infanti mais baratas netshoes

  3. vendita fabbrica armani giacche uomo nero marrone cappotti uomo garantito il prezzo basso emporio armani mens hoodie popolare

    womens blue and white floral skater dresswomens how to buy human hair wholesaleiniki boost navy rhinestoneswomens best sleeping pad

  4. leona pink mid heel court shoes by carvela kurt geiger endource

    wax womens juniors basic stretchy fit skinny jeans at amazon womens jeans storevintage denim style mens o neck brooklyn denim jones mens clothing logo high quality dandybarbour coats online shop barbour sale up to 50 discount onered persian rugs for li…

  5. camiseta reebok el classic preta compre agora dafiti brasil

    zapatillas fila infantilmizuno sala club inagasalho nike psg azul e vermelho futebaskat锚nis nike air max invigor mid feminino compre agora zattini

  6. Nike Air Max Classic BW

    Nike Air Max 270 Femme

  7. rb7051 ky rotary说道:

    rb7051 ky rotary

    yeezy boost 350 reflective adidas ef2367 static staticmen vans og old skool lx vlt white size mens 7 womens 8.5 veggiepuma rihanna fenty velvet womens creeper greypuma womens basket platform ow wn

  8. on the grid magasin

    nike air max 180 ice til kvinder sizeaalborg butikker 氓bningstider julhvidt satin t酶rkl忙de med noder i rosa guld med glanswerner kern dansesko sort skind 5

  9. 55 cart玫es de visita com relevo

    rel贸gio emp贸rio armani ar0690 sem caixa. carregando zoombuy casio vintage series analog digital black dial mens watch aqbrecho online uma op莽茫o para vender coisas novas e usadasrelogio volar nf 104 rel贸gios de pulso no mercado livre brasil

  10. negozio italia tacchetti da calcio nike magista ii fg arancio verde nero scarpe da calcio nike

    womens sequin sneakers custom swarovskiwomens nba jersey with hoodienike air jordan 6 retro infrared white infrared blackwomens nike caldra gold

  11. bast und korbtaschen die sch枚nsten taschen 2018 julies dresscode

    m盲dchen haarband mit schmetterlingen von ernstings family ansehenherz kette damen 925 silber ros茅 gold herz anh盲nger halskette zirkonia 45cm kettenl盲nge kette f眉r damenskagen herren uhr skw6180 amazon.de uhrengardinen wohnzimmer mit kurzgardinen k眉che…

  12. 265564 9572 2 vestido nova maxi chita grid

    zapatillas bajas nike air max 90 essential para hombre negras grissergios sapat锚nis parkshoppingcompre tenis vans vermelho online netshoesalpargatas sapatilha havaianas nova original unissex roupas e

  13. ciao principessa sogno 3 in 1 costume bambina

    nike free rn black stockxleather nike shoes mens bling pinterest.comracer pink nike air max 97 kixifywomens new latest handbag

  14. swiss gear mini boarding bag with rfid canada luggage depot

    9781469360096 nfl dallas cowboys 2019 wall calendar turner licensing calendarbaltimore ravens nfl pro line by fanatics branded womens plus size wiggin long sleeve scoop neckis this the new spurs kit spurskit coys harrykanesports football liverpool fc 2…

  15. auktion kawasaki zx10 mc syd bytter gerne 1989

    t锚nis ever ast jump roxo e i 谩s compre agora netshoesbotina country escamada cano m茅dio escrete whisky carame otenis asics running ge kayano 23 verme ho preto prata cadi esmochi a feminina de rodinhas para notebook e materia esco ar

  16. new balance kinderen schoenen

    tennis pro adidas sokken dames tennis tennisprofijn converse shop online chuck taylor all star city hunter hi top brui leat prachtigkorting nike tanjun wit sneakers dames verkooppuntnike performance zoom assersion basketbalschoenen schwarz

  17. corona extra navy cotton baseball hat trucker snapback hat cap blue vinted

    koloa surf co. thruster logo old school curved bill solid snapbackasos design straw fedora hat in beigenew mens toronto blue jay knitted cuffed pom beanie hat stripedking caps

  18. frapp damen straight jeans hose lang schmales bein druck

    bo sa chane drawstring bag ambskin de mi 茫o origina rt锚nis femininos para aventura netshoesmochi a naranja f 煤o jansport superbreak compr谩 ahora dafititenis adidas origina s superstar 80s branco origina r 339

  19. nouveau en ligne hommes femmes en gros nmd human race pharrell williams remise classique mode chaussures

    mens toiletry bag tomas by muiska leather double zip travel dopp kit sleekcos small shoulder bagthe everyday bagto work to walk around in the city on the roadus adidas by stella mccartney womenmen medium gym bag red 2018a lilly pulitzer beach tote in l…

  20. lentes oakley flak 2.0 xl s 550

    moda feminina mochila de couro estilo 茅tnico flores bordados senhoras meninas bolsa escola grande capacidade paranunca se esconda nas sombras贸culos rayban clubmaster 贸culos masculinoprada tkp 4k0 贸culos de sol

  21. nike indy womens light support sports bra. ca

    women amazon heels by spurr sandals for saleconverse at shoe carnival shoecarnivalxs nike sports bra black nike dri fit sport xs depopamazon.com women sexy lingerie

  22. bridal shower invitations papyrus

    vans era 59 oz canvas dress blue marshmallowcheckered le meilleur prix dans amazonadidas mens predator tango shoes 12 13 artnike air max 97 gs bg black pink white juniors girls trainers 921553

  23. kemei km619 men professional electr end 8 26 2019 10 50 pm

    makeup products online buy makeup sets cosmetics at best priceshair flair soft hoodluxurious face cream3000w household hair dryer professional lightweight negative ion blow dryers

  24. nike mens grey sweatsuit brand new with tags mens grey nike sweatsuit. this is a two piece set with both top an bottom. perfecte weather

    sweaters tommy hilfiger women blue pink striped sweatersmall vest cotton student development movement young girl without rims buckles type bra the little girl bra underwearhello holidays 50 off womens j.crew cotton robeamazon.com beibeiying unisex newb…

  25. 2018 nouveaut茅s rayban 2470 ext茅rieure lunettes

    abito patrizia pepe donna abiti nerofreddo vestiti lunghi di lana abiti in lana per lautunno 2017 fotogallery donnaclickcamicia satinata giallo fluo per uomo costumi adultishein maglione poncho a orlo con frangia girocollo albicocca per tutti i giorni…

  26. nokia x6 accessories my nokia blog 200

    torba podr贸偶na na k贸艂kach model 9222 laurent 65 lr贸偶owa d艂uga cekinowa sukienka na sylwestra o dopasowanym fasonie rybka rozowy swieczorowa suknia balowa suknie balowe xxl zdj臋cie na imgedrozkloszowane sukienki elle.pl trendy wiosna lato 2019 moda

  27. uk plus size women hooded jacket ladies fleece winter casual long

    p.e nation the vault crop sports bralyst american eagle sunburst lace padded halter bralette in redvenus womens scoop front bikini moderate bikini swimsuit bottoms redwomens sports bras seamless racerback fitness cycling workout yoga bra black tagl

  28. oakley online store philippines heritage malta

    odlo jacket primaloft loftone jackets insulated emerald green flash womens clothingred nike tech suitunique multi colors mermaid evening dresses 2018 sexy long eveningbuying guide for womens ski jackets

  29. jordan courtside 23

    novica frangipani tea cup with leaf motifsnike jordan mens jordan hydro 5 cool hematite black sandalconverse chuck taylor 2 low topshiekh womens spica s thong sandal

  30. vans authentic flame wall black rockcitykicks fayetteville

    womens mudd velvet double buckle cork sandalsvans sk8 hi reissue 1966 mens red shoes usabilityus sale vans classic slip on braided suede wild dove womens shoeswomens black guess flip flop sandals

  31. beard shaving kit

    hair dryer and straightener holder diy pinterestdeluxe electric facial spa pores steam skin sauna beauty face mistspil wall hair dryerfaro love your hair single 19mm brush

  32. echarpe foulard femme mode hiver vetement accessoire decontractee

    rusty gorras gorra estilo camionero flashback cat谩logo 7tm blanco gorrasmujer traje sombrerero loco mujer nuevo alice in wonderland disfrazbts kpop antibalas cadete suga jimin v jungkook j esperanza rap monstruo sudadera ch谩ndaljeep usa en venta ropa d…

  33. camisa nike sele莽茫o fran莽a home 2 estrelas 2018 19 vers茫o jogador

    nike air max 90 ultra 2.0 se 876005 002 black white nikeadidas sneakers mens x pharrell williams tennis hu primeknit blackthe north face venture jacket womens rabbit grey heathermens evidence sunglasses

  34. pea coat men designer coats autumn and winter wool hooded trench mens slim black peacoat

    ray ban rb3483 gold metal light brown lenses 5160buy marc by marc jacobs mmj 606 full frame prescription eyeglassesthe best womens winter fashion bootsstylish leather jacket for women nancy

  35. micro touch max personal ear nose neck eyebrow hair trimmer remover shaver brand new

    olay pro x advanced cleansing system amazon.in health personal carewelcome to spazio lighting and furniturevintage 1970s aro mini travel hair dryer case includedwall mounted hooded dryer professional wall mounted hooded hair dryer mount barber beauty s…

  36. arena slide black sandals

    conjunto de beb茅 adidas originals superstar exclusivosnike jordan retro 1 mid negras air force blancas 9us 41hombre vans sk8 hi slim botines moroccan geo negro blancasnike zapatillas nike renew hayward para hombre

  37. sapato social masculino preto confort谩vel parisi

    fendi sandales 脿 d茅coupes laser femme chaussureset collection tendance chic caroll femme la robe qswefioxporte b茅b茅 physiocarrier elephant poche caf茅beret ralph lauren

  38. women sneakers athletic shoes ecco sport intrinsic 2 band

    eliza j sequin velvet sheath dresswomen elegant v neck long sleeve beach dress evening cocktail party maxi long wedding dress at amazon womens clothing storealexander mcqueen skull scarf multicoloured woman official authorized storejumpsuit mysexystyle…

  39. girls dresses suitable for 4 6 years old princess party pretty cute dress

    damska bluza bawe艂niana nadruk serce bordowa bordowybuty cr7buty damskie kozaki dlugieess tricot

  40. jim beam hats说道:

    jim beam hats

    trapper flat bill hat. mlittle snapbacks kids hat specialists kids hat specialistscrimson trucker capnew york jets sideline original fit 9fifty snapback

  41. basketball shoes 6602100 nike kobe ix boys grade school performance basketball white

    off white x nike kyrie 4 black white mens basketball shoes free shipping wherepuma mens drift cat sf shoes black red grey christmas dealshot pink reebok cheap off79 the largest catalog discountsnikelab air vapormax flyknit midnight fog medium olive

  42. santos fc x cruzeiro no pacaembu ingressos a partir de 20 reais meia no tobog茫

    bola de futebol adidas oferta com o melhor pre莽o no buscap茅cadastrar promo莽茫o asics e centaurocamisas de times de futebol clubes santosjaqueta de time americano masculinos casacos no mercado livre brasil

  43. abito ricamato luisa spagnoli in georgette di seta con stola abbinata 9

    donna basse tacco stivaletti con lacci combattimento stile biker militare nuovonero colpi di scena farfalla christina negozio archetipo scarpe da donnahogan new dress x derby in pelle brogue 62 colore nero evolution boutique grigio pellepizzo eleganti…

  44. top of the world florida state seminoles white paul white dad adjustable hat

    ask a question about silver grey flower mesh hat fascinatoraorice genuine soft leather black driving flat cap 2017 autumn winter mens stylish fashion outdoors sport40 famous mad hatter quotes that are insanely irresistibleemilio pucci bucket hat emilio…

  45. birkenstock nordstrom x mayari birko flor sandal

    reebok sneakers classic leather gum sneakerdetails about womens nike free tr 8 white trainers 942888 101lyst puma ignite evoknit lo white vaporous gray peacoat ankle high running shoe 8.5m in white for mennike be true 270 vapormax. m

  46. victorias secret body mist endless night nib victorias secret fragrance body mist sprays limited edition

    queen savage tank top the cloth kingsvintage striped silk blouse button up shirt minimalistblack off shoulder long sleeve top 010475 womens shirts blouseswomen fashion black pu pvc wet look long sleeve shirt blouse tops

  47. childrens black vans

    red off the shoulder bodycon dresspowder pink heelsturquoise and white roshesdeep pink high heels

  48. tommy bahama relax hat

    锌褉芯写邪卸邪 胁械褖械泄 褔械褉械蟹 懈薪褌械褉薪械褌 褋邪泄褌褘泻械写褘 converse chuck tay or a star c assic ow optica white m7652c 褍薪懈褋械泻褋 斜械谢褘泄卸械薪褋泻懈械 蟹懈屑薪懈械 泻褉芯褋褋芯胁泻懈 nike air max 36 41 褉 褉 懈薪褌械褉薪械褌 屑邪谐邪蟹懈薪褋锌芯褉褌懈胁薪褘泄 屑邪谐邪蟹懈薪 褋锌芯褉褌屑邪褋褌械褉 胁 褌褑 褔邪褋 锌懈泻 芯褌蟹褘胁褘

  49. nike women high glitter etsy.com

    nike cuff watchadidas catalog 2017nike max ultra 90 crystals etsy.comnike roshe rose diamond

  50. alden ehrenreich de ralph lauren moda masculina

    chap茅u bon茅 nelore pre莽o 贸timo alta qualidade venda r谩pida. carregando zoomcamisa puma ferrari rosso motorsport esportesmochila hurley sided passe o mouse para ver em zoomtecido tricoline camuflado verde

  51. sklep moda dla m臋偶czyzn m臋skie dodatki torby m臋skie torby sportowe

    adidas florido cape track jacket multicolort锚nis nike air force 1 low retro masculino 0 reviewsround mesa lateral alta red. 30 preto preto stabil tok stok mtenis skechers ultra flex free spirits entrenamiento para dama

  52. first look at the nike odyssey react running shoe

    adidas ultra boost 4.0 dna orca core black whitenew style nike air vapormax flyknit 2. 0 w gunsmoke blue orbit pinkadidas ultraboost laceless bb6135 compare prices onoriginal ziggs mini rda for e free

  53. 20pairs lot women summer socks wedding party angry bird funny socks invisible man short socks play heard colored wholesale socks in socks from womens

    rip curl mens rapture revo wide brim hatburberry women men fashion baseball caps hats high density elastbillionaire boys club mens motor patch white trucker capcute little girl and her beautiful mom in aprons and chef hats are smiling while flattening…

  54. sk盲rmskydd i h盲rdat glas till iphone 7 h盲r

    csipk茅s bokazokni zoknikir谩ly web谩ruh谩zt谩ska david jones n艖i m疟b艖r h谩tizs谩k bordeaastron 贸ra moh谩csi aj谩nd茅kboltspartan judo ruha

  55. 卸械薪褋泻懈械 斜邪谢械褌泻懈 puma 斜邪谢械褌泻懈 eighma 泻褍锌懈褌褜

    miss sixty damen echtleder stiefel mit hohem schaft in schwarzgemijacka herren tief v ausschnitt t shirt basic kurzarm oversize einfarbiges shirtdamen einfarbig hohe taille faltenrock a linie langen rock seitenschlitz belted tasche maxirockzartes kleid…

  56. lyst steve madden glaammar zip embossed sneaker in natural

    converse unisex ct ox black 10clearance vans suede sk8 hi mte shoes 4 12 years kids boysgreat discount vans sk8 hi canvas racing red blue mens skate shoes era old skoolvans japan fall winter

  57. youth tae davis new york giants red pro line name number logo pullover hoodie

    online 2018 los angeles lakers merchandise stitched snapback hats 171new era washington redskins 2016 color rush nfl knit hatjets qb teddy bridgewater very confident he can get back to playing at a high levelmens under armour green hawaii warriors 2018…

  58. one year old birthday party dresses first birthday dresses for baby girls

    marc jacobs snapshot cross body wallet black multinike orange just do it sneakersmichael kors silver tone heart pave necklace michaelloft design r茅gi thonet 谩ll贸fogas thonet old standing coat rack alt stehend garderobe ipari industrial industriell

  59. chaleco tommy hilfiger azul masculino ropa chalecos

    pers枚nlichkeit k swiss sneaker wmns court cheswick damen wei脽 mint schuhedas bild wird geladen kochen ohne kueche 140 rezepte fuer unterwegsc a hosengr枚脽e 38 damen jeans aus denim g眉nstig kaufen63050 39 clogs arbeitsschuh antistatik birki air gr眉n gr枚脽…

  60. ta拧ka p艡es rameno tommy hilfiger v铆nov臎 膷erven谩 b铆l谩 d谩msk茅 online prodej

    adidas sandale do vody 1 2boty na b臎啪ky skol spine rs smart ikona produktuteplu膷k茅 trendov茅 snehule do najtuh拧ej zimy. nepremokav茅raritn铆 leteck茅 hodinky longines

  61. calvin klein sports bra size chart elegant calvin klein women s modern cotton bralette grey heather

    womens gucci belt extra large pearl double gg pearl belt. absolutely fashionprada cahier logo plaque leather belt baggg marmont small matelasse shoulder bag quick look. guccigucci bengal boston 409527 large handbag

  62. air max 270 light blue fury laser fuchsia

    homme lacoste keellson 5 chaussures bateau chaussures chaussureslogiciel gratuit pour d茅velopper un site web le blog des geeks etr茅duction authentique air max 95 femme original baskets panier bionouvelle superstar femme sku

  63. bandage shell shape sexy invisible push up women bra plus size cup e fashion strapless bras adhesive silicone bralette underwear

    dsquared donna multicolor pattern white sneakers d2009 1abiti lunghi cerimonia fantasia abiti in pizzoblack lace halter top bralette and shorts vintage styleblack push up bikini top swimsuit tops

  64. sandalia petite jolie salto laco sapatos para feminino no mercado

    adidas ultraboost uncaged cny review bahasa indonesia english subsadidas consortium x neighborhood x invincible nmd r1 boostadidas agravic alpha vest blueamazing red black adidas mens running shoes sneakers adidas mana

  65. er盲tuotteiden poistomyynti ja alennuser盲t jahtiaitta

    comprar camiseta real madrid 2014 2015 replicas baratas camisetasel bal贸n de la fifa rebotala mitad zip sudadera correr entrenamiento joma carrera hombres medio zip sudadera hombre sudor correrde alta gama combat botas dr martens armada

  66. details about brazil tee brasil throwback world cup soccer t shirt med retro old navy futbol

    2018 nw northwave cycling jersey bicycle shirts maillot ciclismo men short sleeve summer quick dry mtb bike tops racing clothing 120401y t shirts onlinematt niskanen 2007 08 hot prospects 207 jersey patch auto rookie card rcmens college navy seattle se…

  67. 7 rocknight driving polarized wayfarer sunglasses for men al mg lightweight blue mirrored sunglasses uv protection

    nike lebron 15 xv graffiti mens size 10 white black red aq2363 100converse black chuck taylor all star dainty ox sneakers 4 1adidas busenitz pro blackwomens adidas supernova sequence boost 8 running shoes black ur4194

  68. womens black low heel ankle boots. hover to zoom

    mens matte black michael kors watchmichael kors ladies watch portia mk3639 new fashion jewelsmichael michael kors michael michael kors fulton signature small crossbody vanilla 150lyst burberry prorsum fringed suede and calf hair bucket bag

  69. natori cotton sateen essentials pj pants set

    del rossa womens 100 cotton lightweight bathrobe robe 0 3 womenspopular river island ukbuy 4 pcs satin nightwear in pink robesecret treasures womens short sleeve sleep shirt flip flops size 20