首页 \ 问答 \ 微服务之间的通信(Communication Between Microservices)

微服务之间的通信(Communication Between Microservices)

假设您有微服务A,B和C,它们当前都通过HTTP进行通信。 假设服务A向服务B发送请求,从而产生响应。 然后,必须将该响应中返回的数据发送到服务C进行某些处理,最后返回到服务A.服务A现在可以在网页上显示结果。

我知道延迟是实现微服务架构的固有问题,我想知道减少这种延迟的常用方法是什么?

另外,我一直在阅读Apache Thrift和RPC如何帮助解决这个问题。 任何人都可以详细说明吗?


Say you have microservice A,B, and C which all currently communicate through HTTP. Say service A sends a request to service B which results in a response. The data returned in that response must then be sent to service C for some processing before finally being returned to service A. Service A can now display the results on the web page.

I know that latency is an inherent issue with implementing a microservice architecture, and I was wondering what are some common ways of reducing this latency?

Also, I have been doing some reading on how Apache Thrift and RPC's can help with this. Can anyone elaborate on that as well?


原文:https://stackoverflow.com/questions/35673254
更新时间:2023-01-17 10:01

最满意答案

您不需要滚动条滚动。 所有可滚动的小部件都有一个用于滚动的api: xviewyview方法。 滚动条只是调用这些方法的一种方便方法,但它不是唯一的方法。

我不知道滑动会发送什么事件,但您可以绑定到这些事件并直接自己调用xview和/或yview方法。

例如,我们假设触摸是<B1>事件,而滑动是<B1-Motion>事件。 您可以使用这样的滑动动作滚动:

class Example:
    def __init__(self):
        ...
        self.tree = ttk.Treeview(...)
        self.tree.bind("<B1>", self.start_swipe)
        self.tree.bind("<B1-Motion>", self.on_swipe)
        ...

    def start_swipe(self, event):
        self.last_y = event.y

    def on_swipe(self, event):
        # only do the scrolling if the swipe is 10 pixels or more
        if abs(event.y - self.swipe_start) < 10:
            return

        # compute whether we are scrolling up or down
        delta = -1 if event.y > self.last_y else 1

        # remember this location for the next time this is called
        self.last_y = event.y

        # do the scroll
        self.tree.yview_scroll(delta, "units")

You don't need scrollbars to scroll. All scrollable widgets have an api that is used for scrolling: the xview and yview methods. The scrollbar is just a convenient way to call those methods, but it's not the only way.

I don't know what events a swipe will send, but you can bind to those events and directly call the xview and/or yview methods yourself.

For example, let's assume for the moment that a touch is the <B1> event, and a swipe is the <B1-Motion> event. You can scroll with a swiping motion like this:

class Example:
    def __init__(self):
        ...
        self.tree = ttk.Treeview(...)
        self.tree.bind("<B1>", self.start_swipe)
        self.tree.bind("<B1-Motion>", self.on_swipe)
        ...

    def start_swipe(self, event):
        self.last_y = event.y

    def on_swipe(self, event):
        # only do the scrolling if the swipe is 10 pixels or more
        if abs(event.y - self.swipe_start) < 10:
            return

        # compute whether we are scrolling up or down
        delta = -1 if event.y > self.last_y else 1

        # remember this location for the next time this is called
        self.last_y = event.y

        # do the scroll
        self.tree.yview_scroll(delta, "units")

相关问答

更多
  • 在这种特定情况下,最简单的解决方案是使用sticky=(N, E, W) 。 您的代码目前使其粘贴到单元格的顶部和底部( N和S ),导致它在以太网中拉伸或在单元格中居中(例如,在Mac上,滚动条是固定大小的,因此它们将集中而不是伸展)。 由于您希望它“粘贴”在紧靠其上方的小部件的底部,因此您不希望它也“粘住”到其自己单元格的底部。 In this specific case, the simplest solution is to use sticky=(N, E, W). Your code curre ...
  • 所以,我刚刚为我的问题找到了一种解决方法Tkinter似乎在多线程方面存在问题。 所以我只是将Tkinter.Scrollbar更改为ttk.Scrollbar 。 ttk模块是Tkinter的扩展版本,解决了Tkinter模块的一些奇怪行为。 请查看http://docs.python.org/3.1/library/tkinter.ttk.html 更改小部件的模块后,一切都按预期工作! 这个解决方案只是实际问题的解决方法,但它的工作原理! So, I just found a kind of work ...
  • 概观 您只能将滚动条与一些小部件相关联,并且根窗口小部件和Frame不是该组窗口小部件的一部分。 最常见的解决方案是创建一个画布小部件,并将滚动条与该小部件相关联。 然后,在该画布中嵌入包含标签小部件的框架。 确定框架的宽度/高度,并将其馈送到画布scrollregion选项,以便滚动区域与框架的大小完全匹配。 在画布上直接绘制文本不是很难,因此如果框架嵌入式画布解决方案似乎太复杂,您可能需要重新考虑该方法。 由于您正在创建一个网格,所以每个文本项目的坐标将很容易计算,特别是如果每一行的高度相同(如果使用单 ...
  • 滚动条需要将根窗口作为父窗口,而不是树。 scrollbar = Scrollbar(root) The scrollbars need to have the root window as the parent, not the tree. scrollbar = Scrollbar(root)
  • 不是一个完整的答案,但你考虑过创建自己的滚动条看起来像: import tkinter as tk class MyScrollbar(tk.Canvas): def __init__(self, master, *args, **kwargs): if 'width' not in kwargs: kwargs['width'] = 10 if 'bd' not in kwargs: kwargs['bd'] = 0 ...
  • Tk Scrollbar小部件(vbar)是Windows中的本机滚动条。 它的外观取决于Windows主题。 如果重要,请考虑更换工具包; 我知道PyQt4会让你在Windows上设置滚动条的样式。 The Tk Scrollbar widget (vbar) is a native scrollbar in Windows. Its appearance depends on the Windows theme. Consider switching toolkits if it matters; I ...
  • 在向画布添加项目时,必须重新配置scrollregion 。 You must re-configure scrollregion when you add items to the canvas.
  • 您不需要滚动条滚动。 所有可滚动的小部件都有一个用于滚动的api: xview和yview方法。 滚动条只是调用这些方法的一种方便方法,但它不是唯一的方法。 我不知道滑动会发送什么事件,但您可以绑定到这些事件并直接自己调用xview和/或yview方法。 例如,我们假设触摸是事件,而滑动是事件。 您可以使用这样的滑动动作滚动: class Example: def __init__(self): ... self.tree = ttk.T ...
  • 您不希望将文本小部件用作滚动条的主控。 与任何其他窗口小部件一样,如果您在文本窗口小部件中打包或网格化滚动条,则文本窗口小部件将缩小或展开以适合滚动条。 这是你问题的症结所在。 相反,创建一个单独的框架(您已经在做),并将该框架用作文本窗口小部件和滚动条的父框架。 如果您想要滚动条位于其中的外观,请将文本小部件的边框宽度设置为零,然后为包含的框架指定一个小边框。 作为最终的可用性提示,我建议不要使窗口不可调整大小。 您的用户可能比您更了解他们想要的窗口大小。 不要将控制权从用户手中夺走。 这是(大致)我将如 ...
  • 虽然我很少推荐place ,但在利用配置选项时它非常强大。 例如,您可以使用in_指定要相对于此窗口小部件放置的窗口小部件。 您可以使用relx指定相对x坐标,并且可以使用relheight指定高度。 在你的情况下,你可以尝试这样的事情: vscroll.place(in_=txtOutput, relx=1.0, relheight=1.0, bordermode="outside") 如果您想要在某些平台上将滚动条嵌入到文本小部件内部(或曾经是常用的),我建议将文本小部件和滚动条放在一个框架中。您可以 ...

相关文章

更多

最新问答

更多
  • 获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
  • 如何通过引用返回对象?(How is returning an object by reference possible?)
  • 矩阵如何存储在内存中?(How are matrices stored in memory?)
  • 每个请求的Java新会话?(Java New Session For Each Request?)
  • css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
  • 无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
  • xcode语法颜色编码解释?(xcode syntax color coding explained?)
  • 在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
  • 从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
  • 从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
  • 西安哪有PLC可控制编程的培训
  • 在Entity Framework中选择基类(Select base class in Entity Framework)
  • 在Android中出现错误“数据集和渲染器应该不为null,并且应该具有相同数量的系列”(Error “Dataset and renderer should be not null and should have the same number of series” in Android)
  • 电脑二级VF有什么用
  • Datamapper Ruby如何添加Hook方法(Datamapper Ruby How to add Hook Method)
  • 金华英语角.
  • 手机软件如何制作
  • 用于Android webview中图像保存的上下文菜单(Context Menu for Image Saving in an Android webview)
  • 注意:未定义的偏移量:PHP(Notice: Undefined offset: PHP)
  • 如何读R中的大数据集[复制](How to read large dataset in R [duplicate])
  • Unity 5 Heighmap与地形宽度/地形长度的分辨率关系?(Unity 5 Heighmap Resolution relationship to terrain width / terrain length?)
  • 如何通知PipedOutputStream线程写入最后一个字节的PipedInputStream线程?(How to notify PipedInputStream thread that PipedOutputStream thread has written last byte?)
  • python的访问器方法有哪些
  • DeviceNetworkInformation:哪个是哪个?(DeviceNetworkInformation: Which is which?)
  • 在Ruby中对组合进行排序(Sorting a combination in Ruby)
  • 网站开发的流程?
  • 使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)
  • 条带格式类型格式模式编号无法正常工作(Stripes format type format pattern number not working properly)
  • 透明度错误IE11(Transparency bug IE11)
  • linux的基本操作命令。。。