简体   繁体   English

大量数据 - 发送它们的最佳方式是什么?

[英]Large amount of data - what is the best way to send them?

we have this scenario: 我们有这种情况:

A server which contains needed data and client component which these data wants. 包含这些数据所需的所需数据和客户端组件的服务器。

On the server are stored 2 types of data: - some information - just a couple of strings basically - binary data 在服务器上存储了两种类型的数据: - 一些信息 - 基本上只是几个字符串 - 二进制数据

We have a problem with getting binary data. 我们在获取二进制数据时遇到问题。 Both sides are written in Java 5 so we have couple of ways.... 双方都是用Java 5编写的,所以我们有两种方式....

Web Service is not the best solution because of speed, memory etc... 由于速度,内存等原因,Web Service不是最佳解决方案......

So, What would you prefer? 那么,你更喜欢什么?

I would like to miss low level socket connection if possible... 如果可能,我想错过低级插座连接...

thanks in advance 提前致谢

Vitek 维特克

I think the only way to do LARGE amounts of data is going to be with raw socket access. 我认为执行大量数据的唯一方法是使用原始套接字访问。

You will hit the Out of Memory issues on large files with most other methods. 您将使用大多数其他方法在大文件上遇到Out of Memory问题。

Socket handling is really pretty straight forward in Java, and it will let you stream the data without loading the entire file into memory (which is what happens behind the scenes without your own buffering). 套接字处理在Java中非常简单,它可以让您在不将整个文件加载到内存中的情况下流式传输数据(这是在没有自己缓冲的情况下在幕后发生的事情)。

Using this strategy I managed to build a system that allowed for the transfer of arbitrarily large files (I was using a 7+ GB DVD image to test the system) without hitting memory issues. 使用这种策略,我设法建立了一个系统,允许传输任意大的文件(我使用7+ GB DVD映像来测试系统),而不会遇到内存问题。

Take a look at the W3C standard MTOM to transfer binary data as part of a SOAP service. 查看W3C标准MTOM,将二进制数据作为SOAP服务的一部分进行传输。 It is efficient in that it sends as a binary and can also send as buffered chunks. 它是高效的,因为它作为二进制发送,也可以作为缓冲块发送。 It will also interop with other clients or providers: 它还将与其他客户或提供商互操作:

How to do MTOM Interop 怎么做MTOM Interop

Server Side - Sending Attachments with SOAP 服务器端 - 使用SOAP发送附件

You might want to have a look at protobuf , this is the library that google uses to exchange data. 你可能想看一下protobuf ,这是google用来交换数据的库。 Its very efficient and extensible. 它非常有效和可扩展。 On a sidenote, Never underestimate the bandwidth of a station wagon full of 1TB harddisks! 在旁注中,永远不要低估装满1TB硬盘的旅行车的带宽!

I've tried converting the binary data to Base64 and then sending it over via SOAP calls and it's worked for me. 我已经尝试将二进制数据转换为Base64,然后通过SOAP调用发送它,它对我有用。 I don't know if that counts as a web service, but if it does, then you're pretty much stuck with sockets. 我不知道这是否算作一个Web服务,但如果确实如此,那么你几乎都会遇到套接字问题。

Some options: 一些选择:

  • You could use RMI which will hide the socket level stuff for you, and perhaps gzip the data...but if the connection fails it won't resume for you. 您可以使用RMI来隐藏套接字级别的东西,也许gzip数据......但如果连接失败,它将不会为您恢复。 Probably will encounter memory issues too. 可能也会遇到内存问题。

  • just HTTP the data with a binary mime type (again perhaps configuring gzip on the webserver). 只使用二进制mime类型HTTP数据(也可能在Web服务器上配置gzip)。 similar problem on resume. 简历上的类似问题。

  • spawn something like wget (I think this can do resume) 产生类似wget的东西(我想这可以做简历)

  • if the client already has the data (a previous version of it), rsync would copy only the changes 如果客户端已经拥有数据(其先前版本),则rsync将仅复制更改

What about the old, affordable and robust FTP? 旧的,经济实惠且强大的FTP怎么样? You can for example easily embed an FTP server in your server-side components and then code a FTP client. 例如,您可以轻松地在服务器端组件中嵌入FTP服务器,然后编写FTP客户端代码。 FTP was born exactly for that (File Transfer Protocol, isn't it?), while SOAP with attachments was not designed with that stuff in mind and can perform very badly. FTP就是为此而生的(文件传输协议,不是吗?),而带有附件的SOAP并没有考虑到那些东西而设计得非常糟糕。 For example you could have a look at: 例如,您可以查看:

http://mina.apache.org/ftpserver/ http://mina.apache.org/ftpserver/

But there are other implementations out there, Apache Mina is just the first one I can recall. 但是还有其他实现,Apache Mina是我能记得的第一个。

Good luck & regards 祝你好运和问候

Is sneakernet an option? sneakernet是一个选择吗? :P :P

RMI is well known for its ease-of-use and its memory leaks. RMI以其易用性和内存泄漏而闻名。 Be warned. 被警告。 Depending on just how much data we're talking about, sneakernet and sockets are both good options. 根据我们谈论的数据量,sneakernet和套接字都是不错的选择。

Consider GridFTP as your transport layer. GridFTP视为传输层。 See also this question . 另见这个问题

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 输出大量数据的最快方法是什么? - What is the fastest way to output a large amount of data? 从大量文本字段中获取和打印数据的最佳方法? - Best way to grab and print data from a large amount of text fields? 将 memory 中的大量数据写入文件的最快方法是什么? - What is the fastest way to write a large amount of data from memory to a file? 从非常大的结果集中显示数据的最佳方法是什么? - What is the best way to present data from a very large resultset? 将大数据对象缓存到 Hazlecast 的最佳方法是什么 - What is the best way to cache large data objects into Hazlecast 无需让用户等待即可在android中加载大量数据的最佳方法 - Best way to load a large amount of data in android without making the user wait 将XML数据发送到webservices jaxws的最佳方法是什么? - What is the best way to send XML data to webservices jaxws 通过套接字发送多个数据值的最佳方法是什么? - What is the best way to send multiple data values through a socket? 保存少量数据的最佳方法 - Best way to save a little amount of data 处理大型CSV文件的最佳方法是什么? - What is the best way to process large CSV files?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM