Home Php C# Sql C C++ Javascript Python Java Go Android Git Linux Asp.net Django .net Node.js Ios Xcode Cocoa Iphone Mysql Tomcat Mongodb Bash Objective-c Scala Visual-studio Apache Elasticsearch Jar Eclipse Jquery Ruby-on-rails Ruby Rubygems Android-studio Spring Lua Sqlite Emacs Ubuntu Perl Docker Swift Amazon-web-services Svn Html Ajax Xml Java-ee Maven Intellij-idea Rvm Macos Unix Css Ipad Postgresql Css3 Json Windows-server Vue.js Typescript Oracle Hibernate Internet-explorer Github Tensorflow Laravel Symfony Redis Html5 Google-app-engine Nginx Firefox Sqlalchemy Lucene Erlang Flask Vim Solr Webview Facebook Zend-framework Virtualenv Nosql Ide Twitter Safari Flutter Bundle Phonegap Centos Sphinx Actionscript Tornado Register | Login | Edit Tags | New Questions | 繁体 | 简体


10 questions online user: 47

0
votes
answers
39 views
+10

如何在Windows 10觸摸屏環境中測試Web應用程序? (browserstack和sauselabs不起作用)

4

我試圖測試一個網站使用Windows 10的觸摸屏手勢。我們實際上沒有帶觸摸屏的Windows 10設備,但www.browserstack.com和www.saucelabs.com/沒有此選項。如何在Windows 10觸摸屏環境中測試Web應用程序? (browserstack和sauselabs不起作用)

什麼是正確的方式來測試通過Windows 10觸摸屏,實際購買帶觸摸屏的Windows 10設備?

沙发
0
0

雖然SauceLabs確實提供real devices,但他們依靠Appium與設備進行交互。

微軟發佈了Windows硬件實驗室套件(「Windows HLK」)。

還有更多文件here

這似乎是「正確」的方式執行此測試。

+0

謝謝@andrew,我會讓你知道如果這個作品 –

+0

@EricBaldwin,你是怎麼回事? –

+0

Andrew,這看起來像一系列軟件測試來測試實際的觸摸屏硬件 所以我不認爲它適用於我們的使用案例 –

10
votes
answers
26 views
+10

Tornado : support multiple Application on same IOLoop

I'm wondering if it is possible in the Tornado framework to register multiple Application on the same IOLoop ?

Something like

application1 = web.Application([
    (r"/", MainPageHandler),
])
http_server = httpserver.HTTPServer(application1)
http_server.listen(8080)

application2 = web.Application([
    (r"/appli2", MainPageHandler2),
])
http_server2 = httpserver.HTTPServer(application2)
http_server2.listen(8080)

ioloop.IOLoop.instance().start()

Basically I'm trying to structure my webapp so that:

  1. functional applications are separated
  2. multiple handlers with the same purpose (e.g. admin/monitoring/etc) are possible on each webapp
up vote 10 down vote accepted favorite
沙发
+100
+50

The simple thing is if you were to bind your applications to different ports:

...
http_server = httpserver.HTTPServer(application1)
http_server.listen(8080)    # NOTE - port 8080

...
http_server2 = httpserver.HTTPServer(application2)
http_server2.listen(8081)   # NOTE - port 8081

ioloop.IOLoop.instance().start()

This is the base case that Tornado makes easy. The challenge is that by routing to applications at the URI level you're crossing a design boundary which is that each application is responsible for all of the URIs that that are requested by it.

If they all really need to be serviced at the URI level not port, it would probably be best to host different applications on different ports and have Nginx/Apache do the URI routing - anything that involves messing with the Application/Request handling is going to be a world of hurt.

0
votes
answers
34 views
+10

JSP迭代不顯示

0

我傳遞一個列表從servlet到JSP如下:JSP迭代不顯示

<c:forEach items="${sessionScope.messageList}" var="msg"> 
    <tr> 
     <td>Agent ID: <c:out value="${msg.getID()}"/></td> 
    </tr> 
</c:forEach> 

的Web應用程序:

Agent agent = (Agent) request.getSession().getAttribute("agent"); 

List<Message> messageList = agent.mailbox.getMessages(); 
request.setAttribute("messageList", messageList); 

request.getRequestDispatcher("/message.jsp").forward(request, response); 

然後,我在JSP文件如下迭代它執行和工作正常,沒有錯誤等......但是,列表的輸出沒有被顯示。

+0

查看jsp頁面頂部的這條線''%@ page session =「true」%>' –

+1

看看這個pls。它可以解決你的問題https://stackoverflow.com/questions/26652712/foreach-loop-not-displaying-any-output-in-jsp – javatar

+0

@ArvindKatte是行存在。 – Axel

沙发
0
2

我需要安裝JSTL才能使用代碼。

  1. here下載Jar文件,並將它們放在WEB-INF/lib文件夾中。
  2. 如果您使用maven添加依賴項。
  3. 增加您的JSP頁面頂部的標籤庫:<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
  4. 重建項目

現在你可以使用JSTL在JSP。

板凳
0
0

您正在設置請求屬性,但在sessionScope.messageList上迭代。

使用requestScope.messageList或簡單地messageList

+0

嘗試了更改,但仍然是相同的問題 – Axel

+0

然後可能意味着消息列表爲空。使用你的調試器。 –

+0

它不是空的,我調試了servlet並且messageList不是空的。 – Axel

0
votes
answers
26 views
+10

AWS限制訪問端口

-1

請提供一些建議。我們在AWS上有一個實例。它在單個服務器上託管一個Web應用程序。我們想要限制對應用程序的訪問(端口80/443)。我們不能簡單地將通過防火牆的連接限制到一系列白名單IP地址,因爲我們不知道我們的用戶將來自哪裏,或者他們將有靜態地址。他們不太瞭解技術,如果複雜,他們很可能不會連接。AWS限制訪問端口

亞馬遜虛擬私有云是一個解決方案還是另一種解決方案讓我們到達我們想要的地方。我們是一個非盈利機構,不會向人們收費,所以我們希望在我們的預算範圍內完成這項工作。

理想情況下,我們會提供個人登錄名/密碼,我們可以與允許他們訪問網址的人共享。我們不確定如何實現這一點,但我們認爲限制服務器上的訪問必須是可能的,並且需要關於該方法的一些指導。這對我們來說是新的。

感謝您的閱讀。

Howard

沙发
0
1

您可以使用安全組限制對80/443以上的方框的訪問。然後,使用用戶ID和密碼限制對應用程序的訪問。

+0

只允許端口80,443和22通過安全組。不幸的是,該應用程序不包括訪問控制來限制未經身份驗證的觀衆。我很想知道HTTP基本認證是否可以合併到大多數網站中,或者是否需要VPN來限制對AWS中Web應用程序的訪問。謝謝。 – Howard

+1

你不需要VPN;可以合併HTTP基本認證或表單認證。亞馬遜還爲用戶管理Cognito提供了一個解決方案。 –

+0

謝謝,我會嘗試HTTP基本認證。將它集成到Nginx看起來很簡單。 Cognito似乎非常好,但它看起來像我需要某種API來使用它作爲訪問實例的前端。 – Howard

0
votes
answers
29 views
+10

像Facebook Messenger和WhatsApp這樣的應用程序如何發送和接收消息

-1

嗨,大家好,我正在考慮儘快製作一個API,以供網絡,Android和iOS應用程序使用,我正在考慮在其中實現消息功能。我試圖主要理解Facebook Messenger和WhatsApp等應用程序的「接收」方面。我知道用戶發送消息給服務器的發送方式,它保存在數據庫中,但服務器如何將消息發送到接收設備。某種形式的長期投票?像Facebook Messenger和WhatsApp這樣的應用程序如何發送和接收消息

+0

長輪詢是一個請求模型,你的模型正在尋找的是推動模式。而不是請求事件並處理它們,這個模型獲取事件並處理它們 – Kushan

沙发
0
0

不同的應用傾向於使用不同的服務來接收和發送推送消息。在這裏描述或列出這是一個非常廣泛的話題。下面是在我看來,流行的:

火力地堡雲消息(谷歌的可擴展基礎架構)https://firebase.google.com/docs/cloud-messaging/]

Onesignal [https://onesignal.com/]

PubNub [https://www.pubnub.com/]

還有許多其他的服務在那裏,只是谷歌推消息解決方案更多

+0

因此,大多數應用程序在收到推送通知後,在後臺或前臺運行服務以從服務器下載消息?這似乎是一件合乎邏輯的事情,如果我錯了,請糾正我。 @Kushan – ThatOneQuestionn

+0

是的,你說得很對......如果你看看他們的正在運行的服務,你通常會看到一個正在運行的服務,這是爲了傾聽推送消息 – Kushan

+0

感謝你的回答,真的很感激@Kushan – ThatOneQuestionn

72
votes
answers
34 views
+10

How to improve productivity when developing Java EE based web applications

I'd like to know how you address the seemingly low productivity of Java EE-based web application development compared to other technology stacks (Seaside, Ruby on Rails, etc).

The constraints are:

  • The finished web application must be deployable on Java EE compliant application containers
  • If possible, previous investment in Java-based solution should be preserved, i.e. native interoperability with Java-based systems and libraries should be possible
  • Due to team structure, Java as implementation language is preferred, although less exotic JVM-based languages (i.e. Groovy) might be acceptable as well
  • The resulting system needs to be architecturally sound
  • The resulting system needs to be extensible and maintainable

To not let this dwindle into a philosophical discussion, I'm only interested in suggestions that are based on practical experience. Possible examples include domain specific languages, frameworks and MDSD.

If you point to an abstract class of solutions (like MDA / MDSD), please provide details on how you implemented it as well as information about common pitfalls and best practices.

If you disagree on the assumption that Java EE-based web application development implies inferior productivity, I'd like to hear your reasoning as well.

EDIT: As there are a lot less answers than I expected, I'll accept accounts of abortive attempts as well, basically extending the question to "How (not) to improve productivity when developing Java EE based web applications?".

up vote 49 down vote accepted favorite
沙发
+490
+50

我相信 Java EE Java堆棧實際上非常好。解釋Java EE的低生產率有幾個原因:

你只是偷了我的話。難以置信的答案。 - FernandoMiguélez於2009年3月24日15:54

感謝您分享您的經驗! - Nils Wloka 09年3月24日21:42

除非您是提交者,否則Tapestry對於企業使用是不可接受的。它可能很好,它也有一個不可接受的政策,以維持當前穩定的版本。在從4到5的轉換中,4沒有收集錯誤,長時間沒有穩定5。 - Stephan Eggermont 09年6月26日7:23

我不同意“不要使用標準,而是工作的最佳工具”。您的代碼可能會存在很長時間,這可能比“今天的最佳工具”長很多,因此您的雇主可能需要在10到20年的時間內維護您使用工具包/語言編寫的代碼。對其他人完全不了解。概念驗證:Visual Basical停止向後兼容版本6.這意味著這些應用程序停留在時間間隔中,但可能仍然是重要的應用程序。基於標準的項目往往壽命更長,並且有多個實現。 - ThorbjørnRavnAndersen 09年7月10日10:55

“代碼生成很糟糕”:你完全錯了。JEE應用程序中的大多數代碼都是無聊的,重複的,樣板代碼。你必須生成它才能提高效率:你生成無聊的部分,這樣你就可以把時間花在你的應用試圖解決的真正問題上。實際上這就是像Django和Ruby on Rails這樣的框架。我同意UML不能用作編程語言,並且makind序列圖很糟糕:這比編碼慢。建模也不意味著圖形:例如,請參閱xtext等工具。我認為建模是一種快速創建dsl的方法。 - Alain Michel 09年10月29日18:19

+60

Spring Hibernate Wicket 當然有助於簡化和加速Web開發,因為它們提供了高度可測試性和集成性非常好。但即使您有一套良好的開發實踐,它也不足以達到RoR生產力。仍然需要太多的技術和管道。

Grails 可能是失踪的在這張圖片中,我們更接近RoR。這是我的下一個實驗。

BTW,我的MDA經驗與提高生產力相反,所以我不會提及它們(實際上,MDA正在扼殺我們的生產力)。

+50

Javarebel 可以大大減少使用Java進行Web開發所花費的時間。

讓我在這裡引用官方網站:

JavaRebel是一個JVM插件(-javaagent),使您能夠立即查看代碼更改,而無需重新部署應用程序或執行容器重新開始。如果你厭倦了看日誌滾動,並希望看到你的變化以便你繼續前進 - JavaRebel是你最好的朋友。

+30

討論Java EE生產力時的一個重點:您應該使用Java EE 5和EJB3.x,因為與先前版本相比,它們提供了更高的生產力(和功能)。

保持標準Java EE規範絕對重要,例如使用Hibernate代替JPA不利於生產力。在使用JPA時,回歸到Hibernate功能沒有任何限制,但是通過使用Hibernate而不是JPA,您將被鎖定在單個持久性提供程序中而沒有廉價的出路。使用標準背後的整個想法是相同的:概念靈活性(通過插入不同的實現)具有可用的可擴展性(如果絕對必要,使用專有擴展)。Java EE 5和EJB3是朝這個方向邁出的重要一步。當然,你希望最大限度地減少任何專有功能,但如果有些功能似乎絕對必要,那麼它們將成為下一版本中規範的一部分的好跡象......

Java EE生產力的主要障礙在於它的企業重點(報價)比大多數項目所需的要多得多,並且在其遺產中(向後兼容性)。在使用JSF和州管理的表示層中還有很多工作要做 - 請關注 JSR-299 解決了這些改進。 Java EE生產力的主要障礙在於其企業關注點(提供的內容遠遠超過大多數項目所需)以及其遺留(向後兼容性)。在使用JSF和州管理的表示層中還有很多工作要做 - 請關注 JSR-299 解決了這些改進。 Java EE生產力的主要障礙在於其企業關注點(提供的內容遠遠超過大多數項目所需)以及其遺留(向後兼容性)。在使用JSF和州管理的表示層中還有很多工作要做 - 請關注 JSR-299 解決了這些改進。

被“鎖定在一個持久性提供者”聽起來很可怕 - 但實際上,一個合理規模的項目不會切換持久性提供者。因此,使用JPA和Hibernate只會增加更多的抽象和混亂,並會妨礙生產力。 - Daniel Alexiuc於2009年3月23日2:17

我不同意。拒絕持久性API將阻礙任何JEE應用程序的生產力,除了極少數情況:不需要Java中的持久性操作,所有存儲過程方法,僅批處理作業等。在JPA出現之前,我反對使用實體EJB但不再是...... - topchef 09年3月23日4:12

+20

Grails 是一個非常模仿Ruby on Rails的Java webapp框架,具有類似的原則(DRY,CoC)和生產力的提高,但基於現有的Java框架(Spring,Hibernate和其他幾個)。

我一直在使用Grails開展一個探索性項目幾個星期(之前沒有Grails或Groovy的經驗) ),我印象非常深刻。有一些粗糙的邊緣 - 它不像RoR那樣成熟,但你可以快速獲得結果,並且從來沒有感覺到框架正在妨礙你。

這個具體的例子可能最好地說明了這一點:我想在單個網頁上的網格中編輯域對象的2D數組,並發現將結果HTML請求數據自動映射到域對象(由Spring MVC提供,我相信)有一個錯誤,導致一些數據被映射到錯誤的對象。我在網上看了一個小時,但顯然沒有人遇到或解決了這個問題。最終我決定放棄自動映射並“手動”進行 - 然後發現它花了我不超過10行代碼......

+20

經常引用RoR和基於動態語言的類似框架是更高效的環境,但我真的很想知道是否有硬數據支持這一點。這並不容易,因為應該確保她不會將蘋果與橙子進行比較。應該考慮類似項目類型(Web 2.0,企業應用程序)和團隊規模。但是,對於小型項目而言,這些框架確實比Java EE更俱生產力。所以這是一個簡短的參數列表,用於支持這一點以及您可以在Java世界中為它們做些什麼。

Ruby是一種更直觀,更簡潔的語言。你可以用更少的代碼做同樣的事情。

我認為你不能在Java中擁有相同的東西,當然,除非您使用在JVM(JRuby,Scala,Groovy)中運行的動態語言。否則,您的IDE可以提供幫助。在Jave中,IDE是一個必不可少的工具,如果你學會好好使用它(代碼生成,代碼片段,重構)它會回報你。事實上,使用Java IDE可以做很多事情,使用Ruby或Python IDE是無法做到的。此外,您還可以使用靜態類型語言。鍵入可能需要更長的時間,但它可以幫助您避免常見錯誤。

Ruby使用起來更有趣。使開發人員更快樂,更高效。

與上述相同。我認為非常主觀的論點。

約定優於配置使事情更快

像Spring或Guice這樣的依賴注入框架可以提供幫助

Scaffolding,MVC已經為您服務。

Java MVC框架再次提供幫助

數據庫變得簡單。將數據庫項加載為對象。可以動態更改數據庫。

Hibernate,iBatis或其他ORM框架可以提供幫助。使用 Hibernate Tools ,您可以使用yR文件中的RoR實現類似的功能

立即加載新模塊

Maven或Ant Ivy可以提供幫助

輕鬆部署測試

您的IDE或Jetty可以提供幫助。事實上,使用Java

測試與框架集成,調試更容易。使用模擬對像有助於測試

依賴注入框架可以幫助模擬對象。JUnit是單元框架的先驅。我不認為Java不那麼容易測試。

當然,我同意使用框架的概念。儘管如此,您的普通JEE Web應用程序中仍存在大量結構冗餘。關於“簡單數據庫”:我看到許多項目突然停止,當ORM工具的隱藏複雜性由於角落案例或濫用而浮出水面時。 - Nils Wloka 09年3月21日0:20

只是為了澄清。Scala不像其他列出的語言那樣動態輸入。 - Daniel O 2009年4月2日7:24

你是對的。我應該說“面向函數編程”的語言。 - kgiannakakis 09年4月2日在7:50

+10

我肯定會和Hibernate一起討論與持久性相關的東西。

為什麼選擇Spring?

使用Spring代替另一個框架的優點是Springs的理念是“的非侵入性”。通常,當您使用框架時,您很可能會開始依賴於該框架,如果認為應用程序運行的時間較長,那麼您可能會遇到一個不好的問題,然後您還需要進行維護等.Spring使用了這樣的框架。 - 稱為“控制反轉”(IoC)模式基本上你的代碼沒有(它可以,但它沒有)調用Spring,但Spring會打電話給你(好萊塢原則:“不要打電話給我,我會打電話給你”)。例如,您可以 使用普通的POJO (普通舊Java對象),您不必從任何與框架相關的類/接口繼承。軟件工程中的另一個大問題(如果不是最大的問題)是依賴關係。你會盡可能地減少它們,因為它們會讓你的生活更加艱難(特別是在以後的維護中)。通過配置文件和依賴注入模式管理組件的實例化, Spring可以大幅減少組件之間的依賴關係我不想繼續,最好的是你開始閱讀官方 Spring網站

+10

從Jython 2.5開始,您可以使用django來滿足您列出的要求。從django項目生成war文件並將它們部署在J2EE應用程序服務器上非常容易。

JRuby on Rails也是如此。唉,我可能處於Java(技術上)巨大投資的情況。由於句法和部分慣用的相似性,Groovy可能會起作用。Python可能會被拒絕。出於好奇:Jython 2.2是否考慮了生產質量? - Nils Wloka 09年3月21日17:34

我推薦django,因為它不是另一個rails clone,它比rails / grails更適合“企業”的東西。Jython 2.2是穩定的,所以是2.5(它已經超出了上一個測試版)。我不明白為什麼有人會使用2.2,語言已經走了很長一段路。 - Vasil 3月21日'09在18:05

+10

只是想提出另一個想法......你實際上可以使用JRuby和Rails(類似於之前關於Django和Jython的評論)。

如果你使用JRuby和Rails和JRuby Rack(和也許其他一些實用程序......我不是最初實現集成的人,你可以將JRuby Rails添加到現有的Java Web應用程序中。我們有一個使用Tomcat部署的遺留JSP應用程序,現在開始使用Rails添加新頁面,只需要設置(除了在必要時擴展JSP端)。到目前為止它已經非常成功,雖然我們沒有在Rails中實現任何主要的高流量頁面,所以我不知道它的擴展程度如何。

我們可以完全訪問會議上,甚至設置了從Rails頁面調用JSP的機制(例如現有的頁眉和頁腳類型JSP包括)。完全集成2需要一些努力和反複試驗,但如果Rails和JRuby是一個選項,我強烈推薦它(作為Ruby的個人粉絲)。

一位同事涉足JBoss Seam ,這是Gavin King(給我們帶來Hibernate的人)的框架,這是為了模仿Rails。看過兩者後,我覺得Rails更易於開發。 這是為了模仿Rails。看過兩者後,我覺得Rails更易於開發。 這是為了模仿Rails。看過兩者後,我覺得Rails更易於開發。

考慮到JRuby到底有多遠,這聽起來很誘人。Cucumber / RSpec的無縫使用聽起來也很誘人,但我擔心JRuby不會滿足“Java或不那麼奇特的JVM語言”標準。出於好奇:您能否分享有關JSP-Rails-Integration的詳細信息? - Nils Wloka 09年3月23日23:00

我不能進入太多的細節,因為這是我的工作,但我們做了一些事情,比如創建一個jsp幫助器來加載一個jsp,使用我創建的模擬響應...幫助器將獲取將存儲在請求中的變量然後jsp可以參考。 - 邁克斯通2009年3月24日17:46

我們的視圖模板自動調用頁眉和頁腳,我們有一個前置過濾器,它將檢查會話以確保用戶正確登錄(所有3個使用jsp助手調用現有代碼幾乎沒有重複邏輯)。 - 邁克斯通2009年3月24日17:47

我們甚至可以使用JRuby Rack附帶的jsp標籤將一些Ruby部分嵌入到現有的jsp頁面中。有一點需要注意......機架或其他工具正在將會話整數轉換為Longs ...但是一個簡單的JSP過濾器通過觀察變量並在更改時將其轉換回來解決它。 - 邁克斯通2009年3月24日17:54

+10

使用AOP(面向方面??編程)進行日誌記錄,授權等交叉切割。您可以使用Spring AOP或AspectJ。它使代碼混亂,可維護。

+10

過去幾年我使用了 Jboss Seam ,發現它是非常有效的開發方式在Java EE中(利用EJB3,Hibernate,Facelets)。我也做了一些奇怪的PHP編碼,可以老實說,我對Seam更有效率(雖然這可能也表明了我的PHP技能。)

對我來說,有幾個重點將是:

  • 代碼的熱部署(絕對必須具備)
  • 使用Facelets進行乾洗
  • 基於註釋的配置 < li>廣泛的插件組件(尤其是ajax4jsf)
  • Jboss Tools的IDE支持

0

我會選擇用Scala編寫的 Lift框架通過切換到 Scala ,您將看到極大的生產力提升。Scala也非常穩定,從Scala代碼調用Java代碼非常容易。不僅如此,它與Java非常相似,但增加了一些功能。對於某些示例,您應該參考 Java開發人員需要了解的有關Scala的5件事。 Twitter會將部分代碼庫移至Scala。

你永遠不會” 而且由於Lift應用程序是用Scala編寫的,這是一種優雅的新JVM語言,您仍然可以使用自己喜歡的Java庫並部署到您喜歡的Servlet容器中。使用您已編寫的代碼並部署到您已配置的容器中!

您是否在企業環境中擁有Scala或liftweb的真實生活經歷(即客戶通常是風險厭惡的後期採用者)?雖然我發現Scala很漂亮並且很有希望,但我不確定其中任何一個尚未準備好用於生產。 - Nils Wloka 09年3月22日19:52

Scala絕對準備好了。原因是它只是搭載太陽能jvm,這是穩定的。編譯它並不難。我在小型互聯網項目中使用過Scala。我對Lift有些懷疑,雖然很小。innovgames.com希望我能幫助你更多。 - Daniel O Mar於2009年3月26日8:07

0

一些基本規則:

  1. 啟動應用程序服務器 - 在轉變和質量方面取得巨大成功。如果必須,請保留一個Web容器,但在Spring和/或Hibernate中配置所有內容,以使web.xml最小化。

  2. 測試所有內容,您現在可以執行第1步(不需要部署時XML或代碼生成:所有內容都已在開發中配置)。

  3. 使用Wicket實現您的Web層 - 沒有人需要JSP了; Wicket的效率提高了10倍,而且易於測試(參見步驟2)。

  4. 使用SCRUM和敏捷開發方法 < / li>

    結果是Java生產力高達4GL允許 - 我們在 Atomikos 有幾個我們這樣做的遷移項目。因為我們從4GL平台遷移到Java / Java EE,所以我們可以比較兩者中的估計。

    另請參閱此博文: http://blog.atomikos.com/?p=87

    HTH

    蓋伊 > Atomikos 有幾個我們這樣做的遷移項目。因為我們從4GL平台遷移到Java / Java EE,所以我們可以比較兩者中的估計。

    另請參閱此博文: http://blog.atomikos.com/?p=87

    HTH

    蓋伊 > Atomikos 有幾個我們這樣做的遷移項目。因為我們從4GL平台遷移到Java / Java EE,所以我們可以比較兩者中的估計。

    另請參閱此博文: http://blog.atomikos.com/?p=87

    HTH

    蓋伊

-10

嗯,我不是一個真正的Java人,所以我不能說太多,除了... JSF

我們試圖使用它一段時間,這是一場災難。Almots所有基本步驟必須通過很多痛苦,沒有文檔,沒有示例,沒有社區知識。我們使用了Eclipse的一個插件(Exadel Studio),我們看了一些其他的JSF框架,它們都是不兼容的,文檔很少。事實上,在我們嘗試過的所有內容中,只有Sun框架(忘記了它的名稱,基於NetBeans)才能創建一個新的JSF項目,甚至可以開箱即用。其餘的需要多天配置apache和其他東西,對於一個沒有經驗的人來說是一個真正的挑戰(雖然我管理它)。

我們的團隊花了幾個月的時間做了一些事情用ASP.NET幾週。人們對JSF和ASP.NET都缺乏經驗。

如果JSF生態系統仍然像2007年那樣糟糕,我建議完全避免它,無論如何,生產力是不可能的。也許堅持使用JSP或經過時間驗證和發展良好的東西?

JSF並不是那麼糟糕。當然它在某些地方有點難看,但當你使用Facelets和像Seam這樣的框架時,它實際上非常方便。 - 達摩09年3月23日11:45

0
votes
answers
34 views
+10

禁用Azure Web Apps中的一個插槽的交換

0

假設我在Azure中有一個帶有兩個插槽的應用程序:分段和開發。目前,我可以自由地在生產,開發和舞臺之間進行交換。禁用Azure Web Apps中的一個插槽的交換

有沒有辦法禁用交換開發?所以可以交換prod & staging,但不可能用任何東西交換開發。

沙发
0
0

禁用交換在Azure的Web應用程序

如果你想要一個時隙交換產品及舞臺插槽,你可以打開上的臨時槽的自動交換。如果您不想通過開發進行自動交換,我們可以在開發槽中關閉它。我不知道你爲什麼要禁用與開發交換。如果我們手動交換它,我們可以選擇任何我們想要的插槽。我們可以從azure document獲得更多關於交換插槽的詳細信息。

enter image description here

+0

你看,我想發展不下拉爲手動交換槽選擇開店了。我可以這樣做嗎? – faso

+0

根據我的經驗,不支持這樣做。根據我的理解,這個插槽應該是這樣做的。 –

2658
votes
answers
30 views
+10

How to decide when to use Node.js?

I am new to this kind of stuff, but lately I've been hearing a lot about how good Node.js is. Considering how much I love working with jQuery and JavaScript in general, I can't help but wonder how to decide when to use Node.js. The web application I have in mind is something like Bitly - takes some content, archives it.

From all the homework I have been doing in the last few days, I obtained the following information. Node.js

  • is a command-line tool that can be run as a regular web server and lets one run JavaScript programs
  • utilizes the great V8 JavaScript engine
  • is very good when you need to do several things at the same time
  • is event-based so all the wonderful Ajax-like stuff can be done on the server side
  • lets us share code between the browser and the backend
  • lets us talk with MySQL

Some of the sources that I have come across are:

Considering that Node.js can be run almost out-of-the-box on Amazon's EC2 instances, I am trying to understand what type of problems require Node.js as opposed to any of the mighty kings out there like PHP, Python and Ruby. I understand that it really depends on the expertise one has on a language, but my question falls more into the general category of: When to use a particular framework and what type of problems is it particularly suited for?

up vote 1358 down vote accepted favorite
沙发
+13580
+50

You did a great job of summarizing what's awesome about Node.js. My feeling is that Node.js is especially suited for applications where you'd like to maintain a persistent connection from the browser back to the server. Using a technique known as "long-polling", you can write an application that sends updates to the user in real time. Doing long polling on many of the web's giants, like Ruby on Rails or Django, would create immense load on the server, because each active client eats up one server process. This situation amounts to a tarpit attack. When you use something like Node.js, the server has no need of maintaining separate threads for each open connection.

This means you can create a browser-based chat application in Node.js that takes almost no system resources to serve a great many clients. Any time you want to do this sort of long-polling, Node.js is a great option.

It's worth mentioning that Ruby and Python both have tools to do this sort of thing (eventmachine and twisted, respectively), but that Node.js does it exceptionally well, and from the ground up. JavaScript is exceptionally well situated to a callback-based concurrency model, and it excels here. Also, being able to serialize and deserialize with JSON native to both the client and the server is pretty nifty.

I look forward to reading other answers here, this is a fantastic question.

It's worth pointing out that Node.js is also great for situations in which you'll be reusing a lot of code across the client/server gap. The Meteor framework makes this really easy, and a lot of folks are suggesting this might be the future of web development. I can say from experience that it's a whole lot of fun to write code in Meteor, and a big part of this is spending less time thinking about how you're going to restructure your data, so the code that runs in the browser can easily manipulate it and pass it back.

Here's an article on Pyramid and long-polling, which turns out to be very easy to set up with a little help from gevent: TicTacToe and Long Polling with Pyramid.

+4090

I believe Node.js is best suited for real-time applications: online games, collaboration tools, chat rooms, or anything where what one user (or robot? or sensor?) does with the application needs to be seen by other users immediately, without a page refresh.

I should also mention that Socket.IO in combination with Node.js will reduce your real-time latency even further than what is possible with long polling. Socket.IO will fall back to long polling as a worst case scenario, and instead use web sockets or even Flash if they are available.

But I should also mention that just about any situation where the code might block due to threads can be better addressed with Node.js. Or any situation where you need the application to be event-driven.

Also, Ryan Dahl said in a talk that I once attended that the Node.js benchmarks closely rival Nginx for regular old HTTP requests. So if we build with Node.js, we can serve our normal resources quite effectively, and when we need the event-driven stuff, it's ready to handle it.

Plus it's all JavaScript all the time. Lingua Franca on the whole stack.

有趣的是,跨文化個體在主流文化和本土文化之間轉換時轉換方言的做法被稱為“代碼轉換”。 - 邁克爾布萊克本2015年9月8日15:31

就在前幾天,我正在思考如何以某種方式為不同的.js文件分配不同的顏色。客戶端為綠色,服務器端為藍色。我自己一直“迷失”。 - AJB 2015年12月30日18:46

+2090

Reasons to use NodeJS:

  • It runs Javascript, so you can use the same language on server and client, and even share some code between them (e.g. for form validation, or to render views at either end.)

  • The single-threaded event-driven system is fast even when handling lots of requests at once, and also simple, compared to traditional multi-threaded Java or ROR frameworks.

  • The ever-growing pool of packages accessible through NPM, including client and server-side libraries/modules, as well as command-line tools for web development. Most of these are conveniently hosted on github, where sometimes you can report an issue and find it fixed within hours! It's nice to have everything under one roof, with standardized issue reporting and easy forking.

  • It has become the defacto standard environment in which to run Javascript-related tools and other web-related tools, including task runners, minifiers, beautifiers, linters, preprocessors, bundlers and analytics processors.

  • It seems quite suitable for prototyping, agile development and rapid product iteration.

Reasons not to use NodeJS:

  • It runs Javascript, which has no compile-time type checking. For large, complex safety-critical systems, or projects including collaboration between different organizations, a language which encourages contractual interfaces and provides static type checking may save you some debugging time (and explosions) in the long run. (Although the JVM is stuck with null, so please use Haskell for your nuclear reactors.)

  • Added to that, many of the packages in NPM are a little raw, and still under rapid development. Some libraries for older frameworks have undergone a decade of testing and bugfixing, and are very stable by now. Npmjs.org has no mechanism to rate packages, which has lead to a proliferation of packages doing more or less the same thing, out of which a large percentage are no longer maintained.

  • Nested callback hell. (Of course there are 20 different solutions to this...)

  • The ever-growing pool of packages can make one NodeJS project appear radically different from the next. There is a large diversity in implementations due to the huge number of options available (e.g. Express/Sails.js/Meteor/Derby). This can sometimes make it harder for a new developer to jump in on a Node project. Contrast that with a Rails developer joining an existing project: he should be able to get familiar with the app pretty quickly, because all Rails apps are encouraged to use a similar structure.

  • Dealing with files can be a bit of a pain. Things that are trivial in other languages, like reading a line from a text file, are weird enough to do with Node.js that there's a StackOverflow question on that with 80+ upvotes. There's no simple way to read one record at a time from a CSV file. Etc.

I love NodeJS, it is fast and wild and fun, but I am concerned it has little interest in provable-correctness. Let's hope we can eventually merge the best of both worlds. I am eager to see what will replace Node in the future... :)

@nane是的我確實認為他們可以解決這個問題,但是你必須限制自己只使用用類型安全語言編寫的庫,或者接受並非所有的代碼庫都是靜態類型的。但有一種觀點認為:既然你應該為你的代碼編寫好的測試而不管語言是什麼,那麼即使對於動態類型的代碼,你的置信度應該相等。如果我們接受這個論點,那麼強類型的優勢就會減少,從而有助於開發/調試時間,可證明性和優化。 - joeytwiddle 2015年8月23日16:46

@kervin,我同意一些基準會很棒,但我對在網上找到的東西感到很失望。有些人認為.NET性能與Node相當,但它實際上是至關重要的。節點可能很好地提供具有許多並發連接的小消息,但對於繁重的數學計算則不是那麼好。良好的性能比較需要測試各種情況。 - joeytwiddle 2015年8月23日16:59

@joeytwiddle在處理更大的複雜程序和靜態類型檢查時,不會像Typescript那樣幫助Node.js嗎? - CodeMonkey 2015年9月3日6:33

@joeytwiddle的價值,您可以使用stillmaintained.com來確定是否仍然維護npm包(因為大多數都在github上)。此外,npm search和npm show將顯示最後一次發布包的日期。 - Dan Pantry 2015年11月3日12:38

通過將rails與節點進行比較,您會將平台與框架混淆。Rails是Ruby的框架,就像Sails和meteor是Javascript的框架一樣。 - BonsaiOak 2016年2月26日15:10

+2070

To make it short:

Node.js is well suited for applications that have a lot of concurrent connections and each request only needs very few CPU cycles, because the event loop (with all the other clients) is blocked during execution of a function.

A good article about the event loop in Node.js is Mixu's tech blog: Understanding the node.js event loop.

+1270

I have one real-world example where I have used Node.js. The company where I work got one client who wanted to have a simple static HTML website. This website is for selling one item using PayPal and the client also wanted to have a counter which shows the amount of sold items. Client expected to have huge amount of visitors to this website. I decided to make the counter using Node.js and the Express.js framework.

The Node.js application was simple. Get the sold items amount from a Redis database, increase the counter when item is sold and serve the counter value to users via the API.

Some reasons why I chose to use Node.js in this case

  1. It is very lightweight and fast. There has been over 200000 visits on this website in three weeks and minimal server resources has been able to handle it all.
  2. The counter is really easy to make to be real time.
  3. Node.js was easy to configure.
  4. There are lots of modules available for free. For example, I found a Node.js module for PayPal.

In this case, Node.js was an awesome choice.

你是如何主持這樣的?你必須在生產服務器上設置nodejs嗎?在linux中? - Notflip 2014年4月14日15:25

有一些PaaS,如nodejitsu和Heroku。或者你確實可以在linux盒子上設置nodejs,即從amazon ec2。見:lauradhamilton.com/ ... - 哈利年輕人2015年7月15日23:17

在1,814,400秒內訪問200,000次。根本不相關。甚至bash也可以在最慢的服務器上提供許多請求。刮擦服務器。最慢的VM。 - Tiberiu-IonuţStan2016年5月1日10:52

+1050

The most important reasons to start your next project using Node ...

  • All the coolest dudes are into it ... so it must be fun.
  • You can hangout at the cooler and have lots of Node adventures to brag about.
  • You're a penny pincher when it comes to cloud hosting costs.
  • Been there done that with Rails
  • You hate IIS deployments
  • Your old IT job is getting rather dull and you wish you were in a shiny new Start Up.

What to expect ...

  • You'll feel safe and secure with Express without all the server bloatware you never needed.
  • Runs like a rocket and scales well.
  • You dream it. You installed it. The node package repo npmjs.org is the largest ecosystem of open source libraries in the world.
  • Your brain will get time warped in the land of nested callbacks ...
  • ... until you learn to keep your Promises.
  • Sequelize and Passport are your new API friends.
  • Debugging mostly async code will get umm ... interesting .
  • Time for all Noders to master Typescript.

Who uses it?

  • PayPal, Netflix, Walmart, LinkedIn, Groupon, Uber, GoDaddy, Dow Jones
  • Here's why they switched to Node.

是的,我可以用傳統方式回答這個問題。我認為我有資格這樣做,但大部分都已經說過了,我認為一些輕鬆愉快會打破單調。我經常就其他問題提供技術答案。 - Tony O'Hagan 2014年6月14日4:24

使用ES6生成器進行異步代碼可以避免嵌套回調 - 重構於2016年5月19日12:25

@CleanCrispCode:是的!ES6採用了C#style async / await,現在我們可以推出更清晰的異步Node代碼,它也支持傳統的try / catch。2016/17 JS編程人員正在轉向ES6。 - Tony O'Hagan 2016年5月20日0:12

這個“你將感覺安全,沒有你從未需要的所有服務器英國媒體報導”的安全性 - Simone Poggi於2016年7月27日8:19

+600

There is nothing like Silver Bullet. Everything comes with some cost associated with it. It is like if you eat oily food, you will compromise your health and healthy food does not come with spices like oily food. It is individual choice whether they want health or spices as in their food. Same way Node.js consider to be used in specific scenario. If your app does not fit into that scenario you should not consider it for your app development. I am just putting my thought on the same:

When to use Node.JS

  1. If your server side code requires very few cpu cycles. In other world you are doing non blocking operation and does not have heavy algorithm/Job which consumes lots of CPU cycles.
  2. If you are from Javascript back ground and comfortable in writing Single Threaded code just like client side JS.

When NOT to use Node.JS

  1. Your server request is dependent on heavy CPU consuming algorithm/Job.

Scalability Consideration with Node.JS

  1. Node.JS itself does not utilize all core of underlying system and it is single threaded by default, you have to write logic by your own to utilize multi core processor and make it multi threaded.

Node.JS Alternatives

There are other option to use in place of Node.JS however Vert.x seems to be pretty promising and has lots of additional features like polygot and better scalability considerations.

我不確定“如果您的服務器端請求包括阻止操作,如文件IO或Socket IO”在“何時不使用”中列出。如果我的理解是正確的,那麼node.js的優點之一是,它具有強大的異步性,可以在不阻塞的情況下處理IO。所以Node.js可以被視為阻止IO的“治愈方法”。 - Ondrej Peterka 2013年5月24日13:00

@OndraPeterka:你是對的,Node.js可以解決阻塞服務器IO的問題,但是如果服務器上的請求處理程序自己正在阻止調用某些其他Web服務/文件操作,那麼Node.js在這裡就無濟於事了。它僅對來自服務器的傳入請求是非阻塞IO,而不是來自應用程序請求處理程序的傳出請求。 - ajay 2013年6月5日7:28

來自nodejs.org的@ajay他們說“非阻塞I / O”,請檢查你的“當沒有”2和3. - Omar Al-Ithawi 2013年6月6日8:23

在當前版本中,節點實際上通過使用集群支持多核支持。這確實提升了Node應用程序的性能至少兩倍。但是,我認為在穩定集群lib時性能應該超過兩倍。 - Nam Nguyen 2013年9月12日20:05

您可以使用node.js進行繁重的計算。用叉子。請參閱stackoverflow.com/questions/9546225 / ... Node使用集群模塊很好地處理多個內核。nodejs.org/api/cluster.html - 傑斯於2014年5月14日19:44

+410

Another great thing that I think no one has mentioned about Node.js is the amazing community, the package management system (npm) and the amount of modules that exist that you can include by simply including them in your package.json file.

而且這些包都是相對新鮮的,因此它們具有後見之明的優點,並且傾向於符合最近的Web標準。 - joeytwiddle 2013年7月19日21:46

儘管如此,npm上的很多軟件包都很糟糕,因為npm沒有對軟件包進行評級的機制。事後來自CPAN的任何人? - Dan Dascalescu於2014年2月13日13:45

太糟糕了,沒有一個websockets庫可以滿足rfc 6455規範。當得到這個事實時,node.js粉絲是聾啞人,瞎子和瞎子。 - r3wt 2014年8月1日6:32

我不知道你何時發表評論,但截至目前,ws圖書館支持該規範 - Jonathan Gray 11年10月10日4:14

+370

My piece: nodejs is great for making real time systems like analytics, chat-apps, apis, ad servers, etc. Hell, I made my first chat app using nodejs and socket.io under 2 hours and that too during exam week!

Edit

Its been several years since I have started using nodejs and I have used it in making many different things including static file servers, simple analytics, chat apps and much more. This is my take on when to use nodejs

When to use

When making system which put emphasis on concurrency and speed.

  • Sockets only servers like chat apps, irc apps, etc.
  • Social networks which put emphasis on realtime resources like geolocation, video stream, audio stream, etc.
  • Handling small chunks of data really fast like an analytics webapp.
  • As exposing a REST only api.

When not to use

Its a very versatile webserver so you can use it wherever you want but probably not these places.

  • Simple blogs and static sites.
  • Just as a static file server.

Keep in mind that I am just nitpicking. For static file servers, apache is better mainly because it is widely available. The nodejs community has grown larger and more mature over the years and it is safe to say nodejs can be used just about everywhere if you have your own choice of hosting.

簡單的博客仍然可以從Node.js中受益。對於提供靜態文件,您仍然可以使用Node.js,如果負載增加,只需根據當前的最佳實踐在其前面添加Nginx反向代理。Apache httpd服務器是一種正在死亡的恐龍 - 請參閱此Netcraft調查。 - Endrju 2016年1月5日9:53

我會說不然 - 看看ghost.org,看起來很神奇,建立在NodeJs之上 - 協作,實時文章編輯。另外,在NodeJs中創建一個簡單的頁面,比如使用sailsjs.org,很簡單,快速,你不需要為學習任何服務器端編程語言而煩惱--Bery Jun 16 '16 at 9:52

+300

It can be used where

  • Applications that are highly event driven & are heavily I/O bound
  • Applications handling a large number of connections to other systems
  • Real-time applications (Node.js was designed from the ground up for real time and to be easy to use.)
  • Applications that juggle scads of information streaming to and from other sources
  • High traffic, Scalable applications
  • Mobile apps that have to talk to platform API & database, without having to do a lot of data analytics
  • Build out networked applications
  • Applications that need to talk to the back end very often

On Mobile front, prime-time companies have relied on Node.js for their mobile solutions. Check out why?

LinkedIn is a prominent user. Their entire mobile stack is built on Node.js. They went from running 15 servers with 15 instances on each physical machine, to just 4 instances – that can handle double the traffic!

eBay launched ql.io, a web query language for HTTP APIs, which uses Node.js as the runtime stack. They were able to tune a regular developer-quality Ubuntu workstation to handle more than 120,000 active connections per node.js process, with each connection consuming about 2kB memory!

Walmart re-engineered its mobile app to use Node.js and pushed its JavaScript processing to the server.

Read more at: http://www.pixelatingbits.com/a-closer-look-at-mobile-app-development-with-node-js/

+200

Node best for concurrent request handling -

So, Let’s start with a story. From last 2 years I am working on JavaScript and developing web front end and I am enjoying it. Back end guys provide’s us some API’s written in Java,python (we don’t care) and we simply write a AJAX call, get our data and guess what ! we are done. But in real it is not that easy, If data we are getting is not correct or there is some server error then we stuck and we have to contact our back end guys over the mail or chat(sometimes on whatsApp too :).) This is not cool. What if we wrote our API’s in JavaScript and call those API’s from our front end ? Yes that’s pretty cool because if we face any problem in API we can look into it. Guess what ! you can do this now , How ? – Node is there for you.

Ok agreed that you can write your API in JavaScript but what if I am ok with above problem. Do you have any other reason to use node for rest API ?

so here is the magic begins. Yes I do have other reasons to use node for our API’s.

Let’s go back to our traditional rest API system which is based on either blocking operation or threading. Suppose two concurrent request occurs( r1 and r2) , each of them require database operation. So In traditional system what will happens :

1. Waiting Way : Our server starts serving r1 request and waits for query response. after completion of r1 , server starts to serve r2 and does it in same way. So waiting is not a good idea because we don’t have that much time.

2. Threading Way : Our server will creates two threads for both requests r1 and r2 and serve their purpose after querying database so cool its fast.But it is memory consuming because you can see we started two threads also problem increases when both request is querying same data then you have to deal with deadlock kind of issues . So its better than waiting way but still issues are there.

Now here is , how node will do it:

3. Nodeway : When same concurrent request comes in node then it will register an event with its callback and move ahead it will not wait for query response for a particular request.So when r1 request comes then node’s event loop (yes there is an event loop in node which serves this purpose.) register an event with its callback function and move ahead for serving r2 request and similarly register its event with its callback. Whenever any query finishes it triggers its corresponding event and execute its callback to completion without being interrupted.

So no waiting, no threading , no memory consumption – yes this is nodeway for serving rest API.

嗨安舒爾。您能否詳細說明或建議一些關於如何以線程方式發生死鎖的資源。 - jsbisht 2015年3月14日17:10

+160

My one more reason to choose Node.js for a new project is:

Be able to do pure cloud based development

I have used Cloud9 IDE for a while and now I can't imagine without it, it covers all the development lifecycles. All you need is a browser and you can code anytime anywhere on any devices. You don't need to check in code in one Computer(like at home), then checkout in another computer(like at work place).

Of course, there maybe cloud based IDE for other languages or platforms (Cloud 9 IDE is adding supports for other languages as well), but using Cloud 9 to do Node.js developement is really a great experience for me.

實際上,Cloud9 IDE和其他人(我使用的那個)支持幾乎所有類型的Web語言。 - Wanny Miarelli 2015年2月24日18:40

你是個嚴肅的老兄?這是選擇堆棧的標準嗎?:)很高興它為你工作! - matanster 2015年3月18日20:15

+150

One more thing node provides is the ability to create multiple v8 instanes of node using node's child process( childProcess.fork() each requiring 10mb memory as per docs) on the fly, thus not affecting the main process running the server. So offloading a background job that requires huge server load becomes a child's play and we can easily kill them as and when needed.

I've been using node a lot and in most of the apps we build, require server connections at the same time thus a heavy network traffic. Frameworks like Express.js and the new Koajs (which removed callback hell) have made working on node even more easier.

+150

Donning asbestos longjohns...

Yesterday my title with Packt Publications, Reactive Programming with JavaScript. It isn't really a Node.js-centric title; early chapters are intended to cover theory, and later code-heavy chapters cover practice. Because I didn't really think it would be appropriate to fail to give readers a webserver, Node.js seemed by far the obvious choice. The case was closed before it was even opened.

I could have given a very rosy view of my experience with Node.js. Instead I was honest about good points and bad points I encountered.

Let me include a few quotes that are relevant here:

Warning: Node.js and its ecosystem are hot--hot enough to burn you badly!

When I was a teacher’s assistant in math, one of the non-obvious suggestions I was told was not to tell a student that something was “easy.” The reason was somewhat obvious in retrospect: if you tell people something is easy, someone who doesn’t see a solution may end up feeling (even more) stupid, because not only do they not get how to solve the problem, but the problem they are too stupid to understand is an easy one!

There are gotchas that don’t just annoy people coming from Python / Django, which immediately reloads the source if you change anything. With Node.js, the default behavior is that if you make one change, the old version continues to be active until the end of time or until you manually stop and restart the server. This inappropriate behavior doesn’t just annoy Pythonistas; it also irritates native Node.js users who provide various workarounds. The StackOverflow question “Auto-reload of files in Node.js” has, at the time of this writing, over 200 upvotes and 19 answers; an edit directs the user to a nanny script, node-supervisor, with homepage at http://tinyurl.com/reactjs-node-supervisor. This problem affords new users with great opportunity to feel stupid because they thought they had fixed the problem, but the old, buggy behavior is completely unchanged. And it is easy to forget to bounce the server; I have done so multiple times. And the message I would like to give is, “No, you’re not stupid because this behavior of Node.js bit your back; it’s just that the designers of Node.js saw no reason to provide appropriate behavior here. Do try to cope with it, perhaps taking a little help from node-supervisor or another solution, but please don’t walk away feeling that you’re stupid. You’re not the one with the problem; the problem is in Node.js’s default behavior.”

This section, after some debate, was left in, precisely because I don't want to give an impression of “It’s easy.” I cut my hands repeatedly while getting things to work, and I don’t want to smooth over difficulties and set you up to believe that getting Node.js and its ecosystem to function well is a straightforward matter and if it’s not straightforward for you too, you don’t know what you’re doing. If you don’t run into obnoxious difficulties using Node.js, that’s wonderful. If you do, I would hope that you don’t walk away feeling, “I’m stupid—there must be something wrong with me.” You’re not stupid if you experience nasty surprises dealing with Node.js. It’s not you! It’s Node.js and its ecosystem!

The Appendix, which I did not really want after the rising crescendo in the last chapters and the conclusion, talks about what I was able to find in the ecosystem, and provided a workaround for moronic literalism:

Another database that seemed like a perfect fit, and may yet be redeemable, is a server-side implementation of the HTML5 key-value store. This approach has the cardinal advantage of an API that most good front-end developers understand well enough. For that matter, it’s also an API that most not-so-good front-end developers understand well enough. But with the node-localstorage package, while dictionary-syntax access is not offered (you want to use localStorage.setItem(key, value) or localStorage.getItem(key), not localStorage[key]), the full localStorage semantics are implemented, including a default 5MB quota—WHY? Do server-side JavaScript developers need to be protected from themselves?

For client-side database capabilities, a 5MB quota per website is really a generous and useful amount of breathing room to let developers work with it. You could set a much lower quota and still offer developers an immeasurable improvement over limping along with cookie management. A 5MB limit doesn’t lend itself very quickly to Big Data client-side processing, but there is a really quite generous allowance that resourceful developers can use to do a lot. But on the other hand, 5MB is not a particularly large portion of most disks purchased any time recently, meaning that if you and a website disagree about what is reasonable use of disk space, or some site is simply hoggish, it does not really cost you much and you are in no danger of a swamped hard drive unless your hard drive was already too full. Maybe we would be better off if the balance were a little less or a little more, but overall it’s a decent solution to address the intrinsic tension for a client-side context.

However, it might gently be pointed out that when you are the one writing code for your server, you don’t need any additional protection from making your database more than a tolerable 5MB in size. Most developers will neither need nor want tools acting as a nanny and protecting them from storing more than 5MB of server-side data. And the 5MB quota that is a golden balancing act on the client-side is rather a bit silly on a Node.js server. (And, for a database for multiple users such as is covered in this Appendix, it might be pointed out, slightly painfully, that that’s not 5MB per user account unless you create a separate database on disk for each user account; that’s 5MB shared between all user accounts together. That could get painful if you go viral!) The documentation states that the quota is customizable, but an email a week ago to the developer asking how to change the quota is unanswered, as was the StackOverflow question asking the same. The only answer I have been able to find is in the Github CoffeeScript source, where it is listed as an optional second integer argument to a constructor. So that’s easy enough, and you could specify a quota equal to a disk or partition size. But besides porting a feature that does not make sense, the tool’s author has failed completely to follow a very standard convention of interpreting 0 as meaning “unlimited” for a variable or function where an integer is to specify a maximum limit for some resource use. The best thing to do with this misfeature is probably to specify that the quota is Infinity:

if (typeof localStorage === 'undefined' || localStorage === null)
  {      
  var LocalStorage = require('node-localstorage').LocalStorage;
  localStorage = new LocalStorage(__dirname + '/localStorage',
    Infinity);
  }

Swapping two comments in order:

People needlessly shot themselves in the foot constantly using JavaScript as a whole, and part of JavaScript being made respectable language was a Douglas Crockford saying in essence, “JavaScript as a language has some really good parts and some really bad parts. Here are the good parts. Just forget that anything else is there.” Perhaps the hot Node.js ecosystem will grow its own “Douglas Crockford,” who will say, “The Node.js ecosystem is a coding Wild West, but there are some real gems to be found. Here’s a roadmap. Here are the areas to avoid at almost any cost. Here are the areas with some of the richest paydirt to be found in ANY language or environment.”

Perhaps someone else can take those words as a challenge, and follow Crockford’s lead and write up “the good parts” and / or “the better parts” for Node.js and its ecosystem. I’d buy a copy!

And given the degree of enthusiasm and sheer work-hours on all projects, it may be warranted in a year, or two, or three, to sharply temper any remarks about an immature ecosystem made at the time of this writing. It really may make sense in five years to say, “The 2015 Node.js ecosystem had several minefields. The 2020 Node.js ecosystem has multiple paradises.”

我不確定自我傳福音(“考慮購買我的書”)完全適合Stack Overflow。 - TylerH 2015年9月2日21:14

你能在StackExchange傘下找到任何其他地方,我可以在那裡宣傳我的新標題嗎?如果沒有,你能否認為該參考文獻可能直接用於回答這個問題? - Christos Hayward 2015年9月3日11:25

當然,如果它提供了問題的答案並且您明確表明這是您的工作,那麼引用您自己的工作以獲得答案是可以的。這是我的第一個評論所引用的自我傳福音的短語(再次,“考慮購買我的書”部分)。 - TylerH 2015年9月3日13:41

我已經刪除了關於購買我的書的具體內容。 - Christos Hayward 2015年9月4日12:16

+90

If your application mainly tethers web apis, or other io channels, give or take a user interface, node.js may be a fair pick for you, especially if you want to squeeze out the most scalability, or, if your main language in life is javascript (or javascript transpilers of sorts). If you build microservices, node.js is also okay. Node.js is also suitable for any project that is small or simple.

Its main selling point is it allows front-enders take responsibility for back-end stuff rather than the typical divide. Another justifiable selling point is if your workforce is javascript oriented to begin with.

Beyond a certain point however, you cannot scale your code without terrible hacks for forcing modularity, readability and flow control. Some people like those hacks though, especially coming from an event-driven javascript background, they seem familiar or forgivable.

In particular, when your application needs to perform synchronous flows, you start bleeding over half-baked solutions that slow you down considerably in terms of your development process. If you have computation intensive parts in your application, tread with caution picking (only) node.js. Maybe http://koajs.com/ or other novelties alleviate those originally thorny aspects, compared to when I originally used node.js or wrote this.

有許多現有的擴展Node.js應用程序的方法,你似乎沒有提供有關“半生不熟的解決方案”,“糟糕的黑客”和“糟糕的API”聲明的任何參考。介意擴大那些? - Sven Slootweg 2015年3月9日2:40

我將它作為練習留給讀者,但它足以看到所謂的流量控制解決方案。 - matanster 2015年3月9日11:39

這不是一個真正的答案。你聲稱現有的解決方案是“可怕的黑客”,但沒有指出任何一個。您是否認為您可能根本無法理解或了解縮放Node.js應用程序的正確方法? - Sven Slootweg 2015年3月9日19:11

我稍微更新了我的答案。也許你仍然有抱怨,但如果你認為這是錯誤的,你應該對細節進行評論......而不是在答案中指出缺乏。這對社區imo來說會更有成效。 - matanster 2015年3月18日21:38

-20

I can share few points where&why to use node js.

  1. For realtime applications like chat,collaborative editing better we go with nodejs as it is event base where fire event and data to clients from server.
  2. Simple and easy to understand as it is javascript base where most of people have idea.
  3. Most of current web applications going towards angular js&backbone, with node it is easy to interact with client side code as both will use json data.
  4. Lot of plugins available.

Drawbacks:-

  1. Node will support most of databases but best is mongodb which won't support complex joins and others.
  2. Compilation Errors...developer should handle each and every exceptions other wise if any error accord application will stop working where again we need to go and start it manually or using any automation tool.

Conclusion:- Nodejs best to use for simple and real time applications..if you have very big business logic and complex functionality better should not use nodejs. If you want to build an application along with chat and any collaborative functionality.. node can be used in specific parts and remain should go with your convenience technology.

-30
  1. Node is great for quick prototypes but I'd never use it again for anything complex. I spent 20 years developing a relationship with a compiler and I sure miss it.

  2. Node is especially painful for maintaining code that you haven't visited for awhile. Type info and compile time error detection are GOOD THINGS. Why throw all that out? For what? And dang, when something does go south the stack traces quite often completely useless.

雖然您沒有進行編譯時檢查,但JSDoc允許您添加您想要的任何類型信息,以便在您回來時更有意義。正確分解(小)函數通常也很容易理解,因為它們定義良好的環境(閉包)。通常可以通過一些重新分解來解決錯誤的堆棧跟踪,以確保您不會在邏輯之間拆分邏輯,並在其間進行異步回調。將異步回調保存在同一個閉包中可以很容易地進行推理和維護。 - Rich Remer 2014年10月17日20:16

我用了30年的編譯語言,但在使用它大約一年後,JavaScript現在是我選擇的語言。它的效率非常高 - 我可以用比Java C#C ++或C更少的代碼做更多的事情。但這是一種不同的心態。在許多情況下,未鍵入的變量實際上是一個優勢。JSLINT是必不可少的。當您需要同時執行某些操作時,異步回調比您必須使用線程的任何語言更安全,更容易並且最終更高效。而且你必須知道JavaScript,因為它是瀏覽器的語言。 - 詹姆斯2015年5月29日16:19

我對所提出的關切表示同情,並且我注意到已經做出一些努力來解決這些問題,儘管它們肯定不是普遍適用的。有一個名為Tern的驚人項目,可以通過Javascript代碼和庫的靜態分析提供類型派生。它有各種編輯器的插件。還有Typescript,JSDoc和BetterJS。然後是Go,許多編譯到Javascript語言之一! - joeytwiddle 2015年11月26日4:13

0
votes
answers
24 views
+10

使用後端文件nodejs

0

對不起,這可能是一個非常新手的問題,但我對節點和網絡應用程序是新手,只是一直困住這幾天。使用後端文件nodejs

我一直在使用一個名爲「Face ++」的API,它要求用戶上傳圖像來檢測臉部。所以基本上用戶需要將圖像上傳到我的webapps後端,我的後端會對該圖像進行API請求。我以某種方式設法上傳文件在我的節點的後端使用下面提供的教程,但現在我正在努力如何使用這些圖像文件。我真的不知道如何訪問這些文件。我認爲只寫文件路徑/文件名會有所幫助,但事實並非如此。我真的很新,在webapps。

我使用這裏的教程:https://coligo.io/building-ajax-file-uploader-with-node/ 上傳我的文件在後端。

感謝

沙发
0
0

您也可以使用人臉++ REST API節點客戶端 https://www.npmjs.com/package/faceppsdk

按在文檔中它需要在網絡直播的網址。然後,你必須將你的文件上傳到遠程位置(您可以上傳文件到Amazon S3 Bucket

,你也檢查sample codes from Documentation在那裏你可以直接上傳到面對++

+1

謝謝回答。我會研究他們。 – Rikenm

7
votes
answers
32 views
+10

What should be stored in cache for web app?

I realize that this might be a vague question the bequests a vague answer, but I'm in need of some real world examples, thoughts, &/or best practices for caching data for a web app. All of the examples I've read are more technical in nature (how to add or remove cache data from the respective cache store), but I've not been able to find a higher level strategy for caching.

For example, my web app has an inbox/mail feature for each user. What I've been doing to date is storing typical session data in the cache. In this example, when the user logs in I go to the database and retrieve the user's mail messages and store them in cache. I'm beginning to wonder if I should just maintain a copy of all users' messages in the cache, all the time, and just retrieve them from cache when needed, instead of loading from the database upon login. I have a bunch of other data that's loaded on login (product catalogs and related entities) and login is starting to slow down.

So I guess my question to the community, is what would you do/recommend as an approach in this scenario?

Thanks.

沙发
+50
+50

這可能更適合https://softwareengineering.stackexchange.com/,但通常要緩存:

  • 不經常更改的元數據/配置數據。例如國家/州名單,外部資源地址,邏輯/分支設置,產品/價格/稅收定義等。
  • 檢索或生成成本高昂且不需要經常更改的數據。例如報告的歷史數據集。
  • 當前用戶會話唯一的數據。

上面的最後一項是您需要小心的地方,因為您可以通過為每個活動會話的數據添加幾兆字節來大幅增加應用程序的內存使用量。它還意味著不同級別的緩存 - 應用程序範圍,用戶會話等。

通常,您不應緩存處於活動更改中的數據。

在較大的系統中,您還需要考慮緩存的位置。是否可以擁有一個中央緩存服務器,或者它是否足以讓每個服務器/進程處理自己的緩存?

另外:您應該有一些方法來快速重置/使緩存的數據無效。對於較小或較少任務關鍵型應用程序,這可能就像重新啟動Web服務器一樣簡單。對於我所使用的大型系統,我們對大多數緩存數據使用12小時絕對到期時間窗口,但是如果需要,我們可以強制立即到期。

這是一個非常廣泛的問題,答案在很大程度上取決於您正在構建的特定應用程序/系統。我不清楚您的具體情況是否應該緩存所有用戶的消息,但本能地看起來似乎是一個壞主意,因為您似乎有效地緩存了整個數據集。如果新郵件進入或被刪除,這可能會導致問題。你會在緩存中更新它們嗎?這不是簡單地複制後備存儲嗎?

緩存只是一種性能優化技術,與任何優化一樣,在進行實質性更改之前先進行測量,以避免浪費時間優化錯誤的東西。也許你不需要太多的緩存,它只會使你的應用程序複雜化。也許您正在考慮緩存的數據可以更快的方式檢索,或者可以一次檢索更少的數據。

+20

緩存導致重複數據庫查詢的任何內容