2016-05-30 81 views
0

我们构建了一个系统,其中视频存储在mongodb中。这些视频每个都有几百兆字节大小。该系统使用mongoengine在python3中构建。 pymongo和bson的c扩展已安装。Windows上的性能问题mongo

的mongoengine文件的定义是:

class VideoStore(Document, GeneralMixin): 
    video = EmbeddedDocumentListField(SingleFrame) 
    mutdat = DateTimeField() 
    _collection = 'VideoStore' 

    def gen_video(self): 
     for one_frame in self.video: 
      yield self._get_single_frame(one_frame) 

    def _get_single_frame(self, one_frame): 
     if one_frame.frame.tell() != 0: 
      one_frame.frame.seek(0) 
     return pickle.loads(one_frame.frame.read()) 


class SingleFrame(EmbeddedDocument): 
    frame = FileField() 

阅读在Linux中的视频大约需要3到4秒。但是,在Windows中运行相同的代码需要13到17秒。

有没有人有任何有关这个问题和任何解决方案的经验?

我已经想到和测试(没有用):

  1. 增加CHUNKSIZE
  2. 读取视频作为单个斑点,而不使用收率
  3. 文件存储为单个斑点(所以不存储单独的帧)
+0

这是作为Windows服务运行?你是否在Windows服务器或工作站上运行此代码?是否启用NUMA? – profesor79

+0

两台机器上的硬件是否比较相同? Windows版本和磁盘格式类型? NTFS? – Saleem

+0

我已经在笔记本电脑(具有普通硬盘的Windows 7 Core i7)和具有SSD的虚拟机(virtualbox Windows 10)上测试过这种行为。我不知道NUMA,我一定会试一试。 –

回答

0

使用Linux,Windows得不到支持。使用“无限”虚拟内存等其他因素会导致Windows变体出现问题。此线程进一步阐述: Why Mongodb performance better on Linux than on Windows?

+0

不幸的是,系统需要在Windows上运行,因为大多数用户将拥有Windows机器而不是Linux系统。如果我可以选择,我肯定会选择Linux。 –