Netty OIO或NIO(Netty OIO or NIO)

我有多级网络基础设施。 第1层有8台服务器每秒从10000个客户端接收数据。 我想用大约2或3个实例编写代理层来将数据从第1层传输到后端层。

我发现Netty很方便我写这样的程序。 但我还是在NIO或OIO之间混淆,因为我只有8台服务器,同时在Netty的文件中说服务器的OIO连接低于1000,比应该使用NIO多。

我担心使用OIO会阻塞流并使某些消息延迟。 我需要在收到请求后立即回复客户。

愿任何人建议我解决方案,我是网络和Netty的新手。


I have multi stages network infrastructure. Layer 1 has 8 servers receive data from 10000 clients every second. I'd like to write proxy layer with about 2 or 3 instances to transfer data from layer 1 to backend layer.

I found Netty quite convenient for me to write such a program like this. But I still confuse between NIO or OIO, because I only have 8 servers, meanwhile in document of Netty says that OIO for server has lower than 1000 connection, more than that should use NIO.

I'm afraid that using OIO will block the stream and make some messages delay. I need to response to the clients instantaneously after receive the request.

May anyone suggest me the solution, I'm new to network and Netty.


原文:https://stackoverflow.com/questions/20637717
2022-04-05 18:04

满意答案

这应该工作。

    <LinearLayout
    android:weightSum="2"

    android:layout_width="100dp"
    android:layout_height="wrap_content"
    android:orientation="vertical"
    xmlns:android="http://schemas.android.com/apk/res/android" >

    <ImageView 
        android:layout_weight="1"

        android:id="@+id/horizontal_list_image"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center_horizontal" />

    <TextView 
       android:layout_weight="1" 

        android:id="@+id/horizontal_list_text"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center_horizontal"
        android:text="FFFFFFFF"
        android:textSize="15sp"/>
</LinearLayout>

This should work.

    <LinearLayout
    android:weightSum="2"

    android:layout_width="100dp"
    android:layout_height="wrap_content"
    android:orientation="vertical"
    xmlns:android="http://schemas.android.com/apk/res/android" >

    <ImageView 
        android:layout_weight="1"

        android:id="@+id/horizontal_list_image"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center_horizontal" />

    <TextView 
       android:layout_weight="1" 

        android:id="@+id/horizontal_list_text"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center_horizontal"
        android:text="FFFFFFFF"
        android:textSize="15sp"/>
</LinearLayout>

相关问答

更多

RecycleView不显示数据(RecycleView do not displaying the data)

在View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.post_comment_item, parent, false); null放置在父级中View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.post_comment_item, parent, false); I've already solved the issue. The p...

列表视图到Recycleview(Listview to Recycleview)

我修改了你的完整适配器类如下: public class GetAllAllarmiListViewAdapter extends RecyclerView.Adapter<GetAllAllarmiListViewAdapter.MyViewHolder>{ private JSONArray dataArray; private Activity activity; private static LayoutInflater inflater = null; // Provide a s...

使用RecycleView时设置列的宽度(set width of columns when using RecycleView)

如何根据显示打开全尺寸窗口。还应显示标题栏,最小化,交叉选项。 窗口小部件的最大化方法允许您以fullsize打开窗口并显示标题栏 如何设置宽度ID = 20%和名字:40%和姓氏:40%。这个所有列都是相同的。 我认为你的第二个和第三个问题是相同的,你可以使用3个循环视图而不是一个,每列一个 .py : ... from kivy.core.window import Window Window.maximize() ... class RV(BoxLayout): col1 = ...

如何在一个Activity中显示两个RecycleView?(How can I display two RecycleViews in one Activity?)

使用LinearLayout作为两个RecyclerViews父级 您还可以为两个RecyclerViews分配andorid:weight_sum ="1" 它将确保您的两个RecyclerViews都具有相同的尺寸,无论手机的屏幕尺寸有多大。 样品: <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/to...

Android Studio:RecycleView中的项目“跳转”到左侧(Android Studio: Items in RecycleView “jumps” to the left)

好的,我终于明白了。 感谢@Eugen Pechanec(我希望我知道如何正确地提及你),因为布局督察告诉我说有什么问题。 所以,这是我的回收视图本身的代码: <?xml version="1.0" encoding="utf-8"?> <android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="ma...

Horizontal RecycleView不显示其完整内容(Horizontal RecycleView doesn't display its full content)

这应该工作。 <LinearLayout android:weightSum="2" android:layout_width="100dp" android:layout_height="wrap_content" android:orientation="vertical" xmlns:android="http://schemas.android.com/apk/res/android" > <ImageView ...

如何获得RecycleView的滚动坐标?(How is it possible get scroll coordinates of a RecycleView?)

试试这个 int scrollX = recycleView.computeHorizontalScrollOffset(); Try with this int scrollX = recycleView.computeHorizontalScrollOffset();

从Kivy Recycleview获取选定节点(Get selected node from Kivy Recycleview)

请告诉我们你的代码。 在rv.data中,您可以在未选择节点时添加参数'selected'= 0,如果是这样,则可以添加1: class TestRecycleView(RecycleView): def __init__(self, **kwargs): super(TestRecycleView, self).__init__(**kwargs) self.data = [{'name': 'test', 'ind':0,'selected': 0}] cla...

RecycleView不会更新(RecycleView Wont update)

将您的代码更改为此 if (!tags.contains(tag)) { tags.add(tag); Collections.sort(tags, String.CASE_INSENSITIVE_ORDER); adapter.notifyDataSetChanged(); } 因为,以下条件总是错误的 if(!tag.contains(tag)) 这是因为您正在检查值是否包含在该值中。 所以它永远是真的。 如果您正在检查List<St...

RecycleView内的TextView Marquee(TextView Marquee inside RecycleView)

基于此链接 属性singleline因其糟糕的性能而被弃用。 但是我使用了“textview.setSingleLine();” 相反,并没有弃用警告(源代码中也没有)。 所以我认为这可行。 当然,替代方式与列表中的倒数计时器相同,并且自定义视图应该是必要的,但不能避免吨的工作。 Based on this link attribute singleline is deprecated for its bad performance. But I used "textview.setSingleL...

相关文章

更多

[Netty 1] 初识Netty

1. 简介 最早接触netty是在阅读Zookeeper源码的时候,后来看到Storm的消息传输层也由 ...

Netty源码分析

Netty提供异步的、事件驱动的网络应用程序框架和工具,用以快速开发高性能、高可靠性的网络服务器和客户 ...

Java NIO系列教程(一) Java NIO 概述

Java NIO 由以下几个核心部分组成:Channels、Buffers、Selectors。虽然J ...

Netty入门实例-时间服务器

Netty中服务器和客户端之间最大的和唯一的区别是使用了不同的Bootstrap和Channel实现

Netty环境配置

netty是一个java事件驱动的网络通信框架,也就是一个jar包,只要在项目里引用即可。

Netty开发环境配置

最新版本的Netty 4.x和JDK 1.6及更高版本

Java:IO/NIO篇,读写属性文件(properties)

1. 描述 尝试用多种方法读取属性文件。 测试打印系统属性; 测试读取、写入用户属性文件; 测试 ...

solr启动时报错java.nio.channels.OverlappingFileLockException

错误堆栈如下: ===================== 2011-5-10 10:12 ...

storm学习之Netty代替ZMQ

整理自 http://www.csdn.net/article/2014-08-04/2821018/ ...

Netty基于流的传输处理

​在TCP/IP的基于流的传输中,接收的数据被存储到套接字接收缓冲器中。不幸的是,基于流的传输的缓冲器 ...

最新问答

更多

获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)

我用Google搜索了一个解决方案。 “EnumDisplayModeProvider”是我自己设置网站的各种模式的枚举。 public EnumDisplayModeProvider GetDisplayModeId() { foreach (var mode in DisplayModeProvider.Instance.Modes) if (mode.CanHandleContext(HttpContext)) {

如何通过引用返回对象?(How is returning an object by reference possible?)

这相对简单:在类的构造函数中,您可以分配内存,例如使用new 。 如果你制作一个对象的副本,你不是每次都分配新的内存,而是只复制指向原始内存块的指针,同时递增一个也存储在内存中的引用计数器,使得每个副本都是对象可以访问它。 如果引用计数降至零,则销毁对象将减少引用计数并仅释放分配的内存。 您只需要一个自定义复制构造函数和赋值运算符。 这基本上是共享指针的工作方式。 This is relatively easy: In the class' constructor, you allocate m

矩阵如何存储在内存中?(How are matrices stored in memory?)

正如它在“熵编码”中所说的那样,使用Z字形图案,与RLE一起使用,在许多情况下,RLE已经减小了尺寸。 但是,据我所知,DCT本身并没有给出稀疏矩阵。 但它通常会增强矩阵的熵。 这是compressen变得有损的点:输入矩阵用DCT传输,然后量化量化然后使用霍夫曼编码。 As it says in "Entropy coding" a zig-zag pattern is used, together with RLE which will already reduce size for man

每个请求的Java新会话?(Java New Session For Each Request?)

你是如何进行重定向的? 您是否事先调用了HttpServletResponse.encodeRedirectURL()? 在这里阅读javadoc 您可以使用它像response.sendRedirect(response.encodeRedirectURL(path)); The issue was with the path in the JSESSIONID cookie. I still can't figure out why it was being set to the tomca

css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)

我认为word-break ,如果你想在一个单词中打破行,你可以指定它,这样做可以解决问题: .column { word-break:break-all; } jsFiddle演示。 您可以在此处阅读有关word-break属性的更多信息。 I think word-break, with which you can specify if you want to break line within a word, will do the trick: .column { word-break

无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)

我认为您忘记在分类时间内缩放输入图像,如train_test.prototxt文件的第11行所示。 您可能应该在C ++代码中的某个位置乘以该因子,或者使用Caffe图层来缩放输入(请查看ELTWISE或POWER图层)。 编辑: 在评论中进行了一次对话之后,结果发现在classification.cpp文件中错误地删除了图像均值,而在原始训练/测试管道中没有减去图像均值。 I think you have forgotten to scale the input image during cl

xcode语法颜色编码解释?(xcode syntax color coding explained?)

转到: Xcode => Preferences => Fonts & Colors 您将看到每个语法高亮颜色旁边都有一个简短的解释。 Go to: Xcode => Preferences => Fonts & Colors You'll see that each syntax highlighting colour has a brief explanation next to it.

在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)

你考虑过第三方拼写检查吗? 您可以将在C#中开发的自定义WinForms控件插入访问数据库吗? VB6控件怎么样? 如果你能找到一个使用第三方库进行拼写检查的控件,那可能会有效。 Have you considered a third party spell checker? Can you insert a custom WinForms controls developed in C# into an access database? What about a VB6 control? If

从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)

我有同样的问题,因为我在远程服务器上有两个图像,我需要在每天的预定义时间复制到我的本地服务器,这是我能够提出的代码... try { if(@copy('url/to/source/image.ext', 'local/absolute/path/on/server/' . date("d-m-Y") . ".gif")) { } else { $errors = error_get_last(); throw new Exception($err

从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))

我不确定我完全明白你在说什么。 你能编辑你的帖子并包含你正在做的Subversion命令/操作的特定顺序吗? 最好使用命令行svn客户端,以便容易为其他人重现问题。 如果您只是想获取文件的旧副本(即使该文件不再存在),您可以使用如下命令: svn copy ${repo}/trunk/moduleA/file1@${rev} ${repo}/trunk/moduleB/file1 其中${repo}是您的存储库的URL, ${rev}是您想要的文件的版本。 这将恢复该文件的旧版本,包括最高版本